fork download
  1. //Xinnuo Wang CS1A chapter 4, p.221 #7
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * Display Time
  6.  * _____________________________________________________________________________
  7.  * This program accepts a number of secondsto display in a specific timing
  8.  * methods.
  9.  *
  10.  * Computation is based on the formula:
  11.  * time in minutes = seconds / 60
  12.  * time in hours = seconds/3600
  13.  * time in days = seconds/86400
  14.  * _____________________________________________________________________________
  15.  * INPUT
  16.  * seconds : The accepted number in seconds
  17.  * OUTPUT
  18.  * time : The specific way to diaplay the seconds
  19.  *
  20.  ******************************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. int seconds; //INPUT - The accepted number in seconds
  27. int time; //OUTPUT - The specific way to diaplay the seconds
  28. //
  29. //Data Input
  30. cout<<"Enter Number In Seconds"<<endl;
  31. cin>>seconds;
  32. //
  33. //Output
  34. if(seconds>=60&&seconds<3600)
  35. {
  36. time = seconds/60;
  37. cout<< "Time is: " << time<< "minute(s)"<<endl;
  38. }
  39. if(seconds>=3600&&seconds<86400)
  40. {
  41. time = seconds/3600;
  42. cout<< "Time is: " << time<< "hour(s)" <<endl;
  43. }
  44. if(seconds>=86400)
  45. {
  46. time = seconds/86400;
  47. cout<< "Time is: " << time<< "day(s)"<<endl;
  48. }
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5288KB
stdin
4500
stdout
Enter Number In Seconds
Time is: 1hour(s)