Please arrive at 026 Kla early enough to be seated and do the following:
Schedule > Class Calendar lab outline for the week If you arrive late, your lab instructor will not be able to take time away from the other students to fill you in on what you missed.
0 <= sec < 86400 and then displays the time represented by that number in digital format:/* displayTime.cpp There are 86,400 sec. in a 24-hr day, where 0 (midnight) is 00:00:00 and 86,399 is 23:59:59. The following program prompts the user for a number of seconds 0 <= sec < 86400 and then displays the time represented by that number in digital format. It is a modified version of the program on p. 44-45 of [Liang]. Exercise: modify to display leading zeros when necessary. */ #includeusing namespace std; const int SEC_PER_HR = 3600; int main(){ int sec; //user input in seconds int hrs, min, remainingSec; //computed values //prompt and read seconds cout << "enter seconds [0 .. 86400): "; cin >> sec; //echo input cout << sec << " seconds in digital time format is "; //calculate hrs and adjust sec hrs = sec / SEC_PER_HR; sec = sec % SEC_PER_HR; //calculate min and adjust sec min = sec / 60; sec = sec % 60; //display time represented by user input cout << hrs << ":" << min << ":" << sec << endl << endl; return 0; }
Project > Add New Item > Code > c++ file, then name the file displayTime.cpp. Copy the above c++ code from the browser window, paste it into displayTime.cpp and save. Compile and test the program. seconds in digital time format is 0:0:1 seconds in digital time format is 00:00:01
second in digital time format is 00:00:01 conditional operator (p. 86), which can be used for an elegant solution to this problem:
cout << num
<< ((num % 2 == 0) ? " is even" : "is odd");Micro Labs on Campus: In addition to 026 Kla, Visual C++ 2005 Express Edition is installed in 013 Kla and 101 Mck, but it is not installed in other micro labs on campus.
Saving your Lab Work: The My Documents folder on the PCs in 026 Kla is cleared periodically. If you want to save a copy of your lab work, use SSH's File Transfer window to upload your files and/or folders to your shell.uoregon.edu account. Or bring a USB drive with you to your lab and keep your /110 folder stored on that drive.
122 IT Applications/DuckWare CD: Apart from Visual C++, alll the software applications we use in the lab (SSH, FireFox, Fugu, ...) is on the DuckWare CD, and can be installed on your personal computer. The DuckWare CD is available from MicroHelp, 151 McKenzie. See also: OS X applications and Parallels Desktop.
It's important that you are able to follow along as the instructor presents material. If you cannot hear or understand what is being said, please raise your hand and say (polite always works) that you are having difficulty following the presentation. The lab instructor will appreciate your assistance.
Also, please keep in mind that your responsibility is to pay attention and follow the instructor's directions. In particular, you should not be reading email, surfing the web, visiting with other students, etc., during the lab. Save those activities for after the lab.