Real Time calculator

hey guys I was wondering if yall can help me.
the program is to work like this
if there are 60 seconds in a minute it will show the time in number of mintues in that many seconds and 3,600 in an hour the program should display the number of hours in minutes and 86,400 seconds in a day and show the same for days..
so this is what I got but the if statement I don't think is working !!
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
//Time calculator program
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{

double seconds,//seconds data input by the user
       result;//data user should see m either days, minutes, or seconds

     
      

//Getting data from the user
cout << "Please enter the number of seconds ? ";
cin >> seconds;



//if user inputs  86400 or higer should display days
if(seconds >= 86400)
{
result = seconds/86400;
 cout << fixed << showpoint << setprecision(0);	
 cout << "The number of days in "<< seconds <<" seconds is "<< result 
 <<"day/s"<<endl;
	  }
//If user inputs a number between 3600 and 86400 should display hours

else if(3600 <=  seconds < 86400)
{
result = seconds/3600;
 cout << fixed << showpoint << setprecision(0);	
 cout << "The number of hours in "<< seconds <<" seconds is "<<  result 
 <<"hour/s"<<endl;
}

//If user inputs a number between 60 and 3600 it should display minutes

else if ( 60 <= seconds < 3600)
{
result = seconds/60;
 cout << fixed << showpoint << setprecision(0);	
 cout << "The number of minutes in "<< seconds <<" seconds is "<<  result 
 <<"minute/s"<<endl;
}

    
    system("pause");
    return 0;
}
 
	  
Last edited on
Use string or char array.

string T;
T = "days";
cout << T;
Thanks I figure that in c++ you can't display (3600 <= seconds < 86400) like in regular math, you should display (3600<=seconds && seconds<86400) hahah I love programming
Last edited on
yes... I didn't see it :)
Topic archived. No new replies allowed.