1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
//Ashton Dreiling
//Seconds exercise
#include <iostream>
#include <stdlib.h>
using namespace std;
//module prototypes
void calculateDaysHoursMinsAndRemainSecs (double &Days, double &Hours, double &Minutes, double &remainingSeconds,
int seconds);
//global constants
const int VALUETOCALCULATEDAYS = 86400;
const int VALUETOCALCULATEHOURS = 3600;
const int VALUETOCALCULATEMINS = 60;
const int VALUETOCALCULATEREMAINMINS = 60;
int main()
{ //some variables
double Days;
double Hours;
double Minutes;
double remainingSeconds;
int seconds;
cout << "We are going to have you input an amount of seconds to determine the days, hours, minutes, and remaining seconds." << endl;
cout << "Please enter the amount of seconds of your choice." << endl;
cin >> seconds;
cout << "You typed in " << seconds << " seconds." << endl;
cout << "We will now determine the days, hours, minutes, and remaining seconds based off of your input." << endl;
//pass variables to calculate days, hours, minutes, and remaining seconds
calculateDaysHoursMinsAndRemainSecs(Days, Hours, Minutes, remainingSeconds, seconds);
cout << "There are " << Days << " Days." << endl;
cout << "There are " << Hours << " Hours." << endl;
cout << "There are " << Minutes << " Minutes." << endl;
cout << "There are " << remainingSeconds << " remaining seconds." << endl;
system("Pause");
return 0;
}//end main
void calculateDaysHoursMinsAndRemainSecs(double &Days, double &Hours, double &Minutes, double &remainingSeconds, int seconds)
{ //Calculating values
Days=(seconds/VALUETOCALCULATEDAYS);
Hours=(seconds/VALUETOCALCULATEHOURS);
Minutes=(seconds/VALUETOCALCULATEMINS);
remainingSeconds=(seconds % VALUETOCALCULATEREMAINMINS);
}//end calculateDaysHoursMinsAndRemainSecs
|