So I'm supposed to make a program which converts seconds into the equivalent hours, minutes, and seconds (if that makes sense)
For example, if I put in 65 seconds, the result would be 1 minute and 5 seconds.
I made this codes but I can't seem to make the hours work. Help please?
All help would be greatly appreciated.Code:#include <iostream> using namespace std; int main (){ int input, hour, minute, second; cout << "Please enter number of seconds: "; cin >> input; minute = input / 60; hour = input / 3600; second = minute % 60; if (input <= 59) cout << input << " seconds is equivalent to 0 hours, 0 minutes, and " << input << " seconds." << endl; else if (input >= 60 || input < 3600) cout << input << " seconds is equivalent to 0 hours, " << minute << " minutes and " << second << " seconds" << endl; else if (input >= 3600) cout << input << " seconds is equivalent to " << hour << " hours, " << minute << " minutes and " << second << " seconds" << endl; return 0; }


Reply With Quote

Bookmarks