Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (kikuo):

http://prntscr.com/bjfrwv

OpenStudy (kikuo):

http://prntscr.com/bjfrwv @Sachintha What formula would I use to calculate the remaining minutes?

OpenStudy (kikuo):

secondsRemaining = input - days *86400 - hours*3600 - minutes*60 Someone said this, but I'm not sure what they meant

OpenStudy (sachintha):

Is days, hour and minutes are defined? Show me your full code.

OpenStudy (kikuo):

I haven't made it yet. I need a formula for finding the remaining minutes. Here you go. http://prntscr.com/birkvl

OpenStudy (kikuo):

days=seconds/86400 hours=seconds/3600 minutes=seconds/60 I have this But I need the remain secs formula

OpenStudy (kikuo):

//Ashton Dreiling //Seconds exercise #include <iostream> #include <stdlib.h> using namespace std; //module prototypes void calculateDaysHoursMinsAndRemainSecs (double &Days, double &Hours, double &Minutes, double &remainingSeconds, double seconds); //global constants const int VALUETOCALCULATEDAYS = 86400; const int VALUETOCALCULATEHOURS = 3600; const int VALUETOCALCULATEMINS = 60; int main() { //some variables double Days; double Hours; double Minutes; double remainingSeconds; double 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 said you had " << 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; system("Pause"); return 0; } void calculateDaysHoursMinsAndRemainSecs(double &Days, double &Hours, double &Minutes, double &remainingSeconds, double seconds) { Days=(seconds/VALUETOCALCULATEDAYS); Hours=(seconds/VALUETOCALCULATEHOURS); Minutes=(seconds/VALUETOCALCULATEMINS); }

OpenStudy (kikuo):

I have this so far (Not done yet) But I need a formula to find the remaining seconds

OpenStudy (kikuo):

Ah, so I'm on the right path right? I did the days, hours, and mins right correct? @Sachintha

OpenStudy (kikuo):

Your post disappeared? I didn't understand what he meant by input

OpenStudy (kikuo):

@Sachintha

OpenStudy (sachintha):

I think you have to change the seconds to days, hours, minutes and seconds without total hours, minutes .. gh ex: 54055s = 0 days 15hr 0min 55s If so your equations are wrong. The sec remaining equation is meaning less with your day, minutes, hours variables since it simplifies to: sec's remaining = input - (days+hours+mins) which is wrong.

OpenStudy (kikuo):

Here I'll show you what the book says and you decide if the equations are correct or not http://prntscr.com/bjg99u

OpenStudy (sachintha):

According to the book your equations are correct.

OpenStudy (sachintha):

You use this equation for remaining seconds, sec remaining = seconds%60

OpenStudy (kikuo):

seconds%60? @Sachintha

OpenStudy (sachintha):

Yes it's the modulus sign. Run the program and check whether it outputs correctly.

OpenStudy (kikuo):

http://prntscr.com/bjhbza @Sachintha This is what it said

OpenStudy (sachintha):

Why did you put the type of seconds as double?

OpenStudy (kikuo):

In case they put in a decimal.

OpenStudy (kikuo):

@Sachintha Do you know how to fix that error tho : p

OpenStudy (sachintha):

Change it to int.

OpenStudy (kikuo):

Why so?

OpenStudy (sachintha):

Because I think it is a data type exception. :3

OpenStudy (kikuo):

Would you explain? ^.^ @Sachintha

OpenStudy (kikuo):

//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

OpenStudy (kikuo):

@Sachintha Alright. Here is finished product. Type if 86,400 when you run. Tell me if there are any logic errors when you run. : )

OpenStudy (sachintha):

I am getting some other errors. Did it work on your compiler?

OpenStudy (kikuo):

Yes

OpenStudy (kikuo):

@Sachintha

OpenStudy (sachintha):

I tried it on another compiler. It works perfectly. :D

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!