fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 221, 7
  2. //
  3. /**************************************************************
  4.  * Calculate given second
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will calculate the seconds given into hours and days
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * seconds : the given seconds
  11.  * OUTPUT
  12.  * days : the calculated days
  13.  * hours : the calculated hours
  14.  * mins : the calculated minutes
  15.  **************************************************************/
  16. #include <iostream>
  17. #include <iomanip>
  18. #include <cmath>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. float seconds,
  24. days,
  25. hours,
  26. mins;
  27. cout<<"Please enter the amount of seconds you want to calculate"<<endl;
  28. cin >> seconds;
  29. days = seconds / 86400;
  30. hours = seconds / 3600;
  31. mins = seconds / 60;
  32. if (seconds>=86400)
  33. {
  34. cout<<"There is "<<days<<"days in seconds"<<endl;
  35.  
  36. }
  37. else if (seconds>=3600)
  38. {
  39. cout<<"There is "<< hours <<" hours in seconds"<<endl;
  40. }
  41. else if (seconds>=60)
  42. {
  43. cout<<"There is " << mins << " minutes in seconds"<<endl;
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Please enter the amount of seconds you want to calculate