//Nathanael Schwartz CS1A Chapter 4, P. 220, #7
//
/*******************************************************************************
*
* CONVERT SECONDS TO A DIFFERENT MEASUREMENT OF TIME
* ______________________________________________________________________________
* This program asks the user the a certain number of seconds. Depending on the
* number of seconds entered the program will convert it to minutes, hours, and
* days, unless the entered time is under 60 seconds.
*
* Computations are Based on the Formula:
* minutes = seconds / 60
* hours = seconds / 3600
* days = seconds / 86400
* ______________________________________________________________________________
* Input
* seconds : the number if second entered by the user
*
* Output
* minutes : the number of minutes for the entered seconds
* hours : the number of hours for the entered seconds
* days : the number of days for the eneterd seconds
*******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
// Define variables
float seconds; // INPUT - the number of seconds entered
float minutes; // OUTPUT - the number of minutes for the entered seconds
float hours; // OUTPUT - the number of hours for the entered seconds
float days; // OUTPUT - the number of days for the entered seconds
// Ask the user for the amount of seconds
cout << "Enter the number of seconds:\n";
cin >> seconds;
cout << "The number of seconds entered is " <<seconds <<" seconds\n";
// Caluclate time
minutes = seconds / 60;
hours = seconds / 3600;
days = seconds / 86400;
// Output results
cout << fixed << setprecision(2);
if (seconds < 60 && seconds >= 0)
cout << "There are " <<seconds <<" seconds\n";
else if (seconds >= 60 && seconds < 3600)
cout << "There are " <<minutes <<" minutes in " <<seconds <<" seconds\n";
else if (seconds >= 3600 && seconds < 86400)
cout << "There are " <<hours <<" hours in " <<seconds << " seconds\n";
else if (seconds >= 86400)
cout << "There are " <<days <<" days in " <<seconds <<" seconds\n";
else
cout << "The number entered is invalid\n";
return 0;
}