Ok, so I'm studying with SAMS C++ Primer Plus (Fifth Edition). In chapter 3 "Dealing With Data," programming exercise #4
"Write a program that asks the user to enter the number of seconds as an integer value (use type long) and that then displays the equivalent time in days, hours, minutes and seconds. Use symbolic constants to represent the number of hours in the day, the number of minutes in an hour, and the number of seconds in a minute."
This is driving me up a wall. I can't figure out how to do this.
This is what I've got so far...
[color=Blue]// Converting an input of seconds to
// Days, Hours, Minutes and Seconds.#include
using namespace std;
const int HoursInDay = 24;
const int MinutesInHour = 60;
const int SecondsInMinute = 60;
cout << "This program will turn your seconds into days," <br /> << " hours, minutes and seconds." << endl;<br /> cout << "Enter the amount of seconds:__________";<br /> cin >> InSeconds;
cout << "That's " << InSeconds / (SecondsInMinute * MinutesInHour * HoursInDay) << " day(s)..." << endl;<br />
return 0; [/color]
I'm not sure where to go from here. I'm sure that somehow the Modulus "%" has to come into play, but I'm not sure how. After calculating the number of days, that total should be subtracted, and the remainder used to calculate the remaining number of hours, minutes, and seconds, etc.
Any help would be greatly appreciated!!
Everyone is entitled to their own opinion... not their own facts.