fork download
  1. //Charlotte Davies-Kiernan CS1A Chapter 4 P.221 #7
  2. //
  3. /******************************************************************************
  4.  *
  5.  * Comput Diversion of Seconds
  6.  * ____________________________________________________________________________
  7.  * This program will display an amount of time corresponding with the amount
  8.  * of seconds the user has decided to enter. If large enough it will compute
  9.  * minutes, even larger then it will compute hours, and then even larger it
  10.  * will convert to days.
  11.  *
  12.  * formula's used are:
  13.  * minutes = seconds / 60.0
  14.  * hours = seconds / 3600.0
  15.  * days = seconds / 86400.0
  16.  * ____________________________________________________________________________
  17.  * INPUT
  18.  * seconds //the amount of seconds the user has decided to enter
  19.  *
  20.  * OUTPUT
  21.  * minutes //the amount of minutes the seconds the user has entered converts to
  22.  * hours //the amount of hours the seconds that are entered converts to if large enough.
  23.  * days //the amount of days the seconds that are entered converts to if large enough.
  24.  *****************************************************************************/
  25. #include <iostream>
  26. #include <iomanip>
  27. using namespace std;
  28. int main()
  29. {
  30. float days; //OUTPUT - seconds entered converted to hours if large enough
  31. float hours; //OUTPUT - seconds entered converted to hours if large enough
  32. float minutes; //OUTPUT - seconds entered convereted to minutes
  33. long long seconds; //INPUT - seconds that are entered by the user
  34. //
  35. //Get user's amount of seconds
  36. cout << "Enter an amount of seconds larger than 60, with no comma!" << endl;
  37. cout << "For example, 6000." << endl;
  38. cin >> seconds;
  39. cout << "You've entered " << seconds << "!" << endl << endl;
  40. //
  41. //Calculate
  42. if (seconds >= 60){
  43. minutes = seconds / 60.0;
  44. cout << "That's approximatley " << minutes << " minutes!" << endl;}
  45. if (seconds >= 3600){
  46. hours = seconds / 3600.0;
  47. cout << "That's approximatley " << hours << " hours!" << endl;}
  48. if (seconds >= 86400){
  49. days = seconds / 86400.0;
  50. cout << "That's approixamtely " << days << " days!" << endl;
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5320KB
stdin
10000
stdout
Enter an amount of seconds larger than 60, with no comma!
For example, 6000.
You've entered 10000!

That's approximatley 166.667 minutes!
That's approximatley 2.77778 hours!