Engr 123 January 11, 2016 Assignment 1 Due: January 20, 2016

advertisement
Engr 123
Assignment 1
Lines
January 11, 2016
Due: January 20, 2016
Write a C# console program to input an integer number of seconds from the keyboard
and outputs the number of days, hours, minutes, and seconds corresponding to the input.
For example, your program output might look like this:
Enter the number of seconds 54302
54300 seconds corresponds to 0 days, 15 hours, 5 minutes, and 2
seconds.
If the number entered by the user is a negative number, your program should print the
message: Error! Cannot enter a negative number.
The next page has a design for the solution to this problem. Follow the program design
and write the implementation code as a console application in C#.
After you get your program running correctly, copy the design from the following page to
the project folder as a doc or docx file. Right click on the project folder and choose Send
To → Compressed zip file. Rename the compressed zip file as Asn01XXX.zip where
XXX are you three initials. Upload the renamed file to
\\cecsfp01\users\everyone\engr123.
Name: Joe Student
Date: January 20, 2016
Assignment: Assignment 1
This program inputs an integer representing a number of seconds.
converts this input to hours, minutes, and seconds and prints the
result.
Design
main()
{Issue prompts for a positive integer in seconds.
if (input < 0)
{Print message indicating an error
}
else
{days = input/(24 x 3600)
hours = (input – days*24*3600)/3600;
minutes = (input – days*24*3600 – hours * 3600)/60
secondsOut = input – days*24*3600 – hours*3600 – minutes*60
Print message giving the value of hours, minutes, secondOut
}
return;
} //End of main code
It
Download