Help with Time programming

Hello, I need help with my programming project here. My project was simple time converter which i manually plus the time(convert from GMT+8 to other time). However I am having trouble for some country time for example Myanmar, which is GMT +6.30.Because when I i input the time time(1500 for example, so for myammar it will be 1500-130 which is 1370(it should be 1330) how can I solve this problem? and how do I make the time display the 1st zero if the time was 0155? and how do i limit to 0000 and 2359(like example 0100 - 130 will become -30 but not display 2330.

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
  #include <iostream>

using namespace std;

float time,x,a,b,c,d,e,f,g,h;

int main()
{
cout<<"Welcome to Malaysia Time Zone Converter";
cout<<"\nEnter the time: ";
cin>>time;
cout<<"\n1.China\n2.Korea\n3.Thailand\n4.Japan\n5.Myanmar";
cout<<"\nPlease pick the country you prefer in the list above: ";
cin>>x;

a = time;//China
b = time + 100;//Korea
c = time - 100;//Thailand
d = time + 100;//Japan
e = time - 130;//Myanmar

if (x==1)
{
cout<<"The time in China is: "<<a<<endl;
}

if (x==2)
{
cout<<"The time in Korea is: "<<b<<endl;
}

if (x==3)
{
cout<<"The time in Thailand is: "<<c<<endl;
}

if(x==4)
{
cout<<"The time in Japan is: "<<d<<endl;
}

if(x==5)
{
cout<<"The time in Myanmar is: "<<e<<endl;
}

}
Last edited on
integer 1500 - integer 0130 = 1370, but time is not decimal. Think more of 15.0 - 1.5 = 13.5, then 60 * .5 = 30, you have your 13:30.
Topic archived. No new replies allowed.