Invisible if-else block

Please give me an idea of why the minutes if-else block doesn't show in the command prompt window.
Thanks


#include <iostream>

using namespace std;

//function prototypes
double divideSeconds(double seconds, double &minutes, double &hours, double &days);

//global constants
const double SECONDS_MINUTES = 60.00; //no. seconds per minute
const double SECONDS_HOURS = 3600.00; //no. seconds per hour
const double SECONDS_DAYS = 86400.00; //no. seconds per day

int main()
{//begin m.
//variables
double numSeconds = 0;
double numMinutes = 0;
double numHours = 0;
double numDays = 0;
;
//title
cout<<"Time Calculator that Converts Seconds"<<endl;
//directions and prompt
cout<<"Type a number of seconds to see the conversion of the number of days, hours, minutes, and seconds."<<endl;
cout<<"One day has 86400 seconds, an hour has 3600, and a minute has 60 seconds."<<endl;

cout<<"Type seconds, then press enter";
cout<<endl;
cin>>numSeconds; //numMinutes, numHours, numDays; //retrieve and display no. of seconds


divideSeconds(numSeconds, numMinutes, numHours, numDays);

system("Pause");

return 0;
}//end m.

double divideSeconds(double seconds, double &minutes, double &hours, double &days)
{
days = seconds / SECONDS_DAYS;
if(seconds >= 86400 && days <= 86400)
cout<<"Days: "" "<<days<<endl;
else if(seconds < 86400)
cout<<"Days: 0 "<<endl;

hours = seconds / SECONDS_HOURS;
if(seconds >= 3600 && hours <= 3600)
cout<<"Hours: "" "<<hours<<endl;
else if(seconds < 3600)
cout<<"Hours: 0 "<<endl;

minutes = seconds / SECONDS_MINUTES;
if(seconds >= 60 && minutes <= 60)
cout<<"Minutes: "" "<<minutes<<endl;
else if(seconds < 60)
cout<<"Minutes: 0 "<<minutes<<endl;
else
cout<<"Try again?"<<endl;


return 0;
}

Depends on your data input.

In divideSeconds(), for any number big enough, minutes will always be greater than 60. The same will happen with hours and days as the number gets bigger.

Your code seems deliberately written to avoid displaying > 60 mins or > 3600 hrs or > 86400 days.

So what're your true intentions?
The assignment is to convert the number of seconds input by user into days, hours, and minutes. The days and hours convert just fine - calculating and displaying but the minutes don't show up at all on the console.

I had the code for minutes exactly the same as hours and days, that didn't work so I changed the 3rd to last line of the 'minutes' block to see if that would make it show up.

the (cout<<....minutes<<I added - minutes here<<endl;

It converts each type separately ( seconds to days) hours, minutes.
It doesn't combine the total into[xxxxxxxxseconds = days?, hours?, and hours?] It is only supposed to calculate and display [xxxxxx seconds = days?];
[seconds = hours?]; and the same for minutes.

So somewhere I am missing something or have added something that's not right, but I don't see it.

Thanks

1
2
3
"Days: "" 
"Hours: "" "
"Minutes: "" " 


Why the extra double quotes here?

In answer to your question:
 
minutes = seconds / SECONDS_MINUTES;


This will return the total number of minutes, not the remaining number of minutes after taking into account hours and days. A better way of implementing this would be to use the % (modulus) operator.

Please use code tags in future [ code ] [ /code] (without the spaces). It will make your life easier and our life easier and you will get more help.
Ok, it does work. I reread the problem and it is doing what is asked for.

Thank you and sorry for the false alarm.
We aren't at modulus yet beyond seeing the symbol. Not at code tags either. Do you put them at the beginning and end of each function?

Double quotes: it seems we have been using them to make sure a space is held.

Thanks
Topic archived. No new replies allowed.