whats wrong with my code!!!

people

i dont know whats wrong
the if - statment dont show it only show the first question...


its suppose to enter the time as hh:mm:ss ---> then apply this code
1
2
3
4
5
6
if(
        h>=0 && h <=60&&
        m>=0 && m <=60&&
        s>=0 && s <=60
   )
//----> the rest of the code  


if not show
invalid time 
and exit
but it always show invalid time automatically after input the accelration
the question is : Write a program to ask user to input an acceleration (km/hour) and the riding time (hh:mm:ss)
and determine which gear the bicycle is in at that time. Print the velocity and the gear number to
the screen. Limit the maximum velocity to 100km/hr. For any velocities that are on the border of
a gear change, use the lower gear. Your program should allow the user to repeat this calculation
as often as the user wishes.


my code is..
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <iostream>
#include<cstdlib>
#include<stdio.h>

using namespace std;

/** Showing the introduction screen and the user maual... */
void splash(void) {
	cout << "   ********************************************************\n";
	cout << "   *                                                      *\n";
    cout << "   *            Velocity And Gear Programme ..            * \n";
    cout << "   *         By:*****\n";
    cout << "   *                                                      *\n";
	cout << "   ********************************************************\n\n";

	cout<<endl ;
	system ("PAUSE");
	system ("cls");
	cout << "****************************************************************\n";
	cout << "*               USER MANUAL                                    *\n";
    cout << "* FIRST :The programme will ask you to input the accelration   * \n";
    cout << "* SECOND : The programme will ask you to input the time        *\n";
    cout << "* THIRED : The programe will calcluate the velocity            *\n";
	cout << "****************************************************************\n\n";

    system ("PAUSE");
	system ("cls");
}
/** Showing the introduction screen and the user maual... */

double Velocity(double accel,double ntime)// to calcluate the Volcity
{
    double Velocity = accel*ntime;

    return Velocity;
}


int main ()
{
    double accel;
    double ntime;
    char choice;
    char time[8];
	double h=0, m=0, s=0;
    splash();

do
        {
            cout<<"What was your Accelaration in (km/hour)  :  ";
    cin>>accel;

    cout<<"\nWhat was your riding time in hr.min :  ";
    gets(time);

	h=(time[1]+(10*(time[0])))-528;
	m=(time[4]+(10*(time[3])))-528;
	s=(time[7]+(10*(time[6])))-528;
//------>start if for the time..
if(
        h>=0 && h <=60&&
        m>=0 && m <=60&&
        s>=0 && s <=60
   )

    {

    cout<<"YOUR time is: "<<time[0]<<time[1]<<":"<<time[3]<<time[4]<<":"<<time[6]<<time[7]<<endl; //OR:

    double ntime=h+m/60+s/3600;

    cout<<"/n your time is"<<ntime;
   //-------->the if for velocity..
   Velocity(accel,ntime);
        if (Velocity(accel,ntime)>=0 && Velocity(accel,ntime)<4)
        {
            cout<<"\nyour Velocity was    "<<Velocity<<endl;
            cout<<" YOUR GEAR IS : 1";
        }
        else if (Velocity(accel,ntime) >=4 && Velocity(accel,ntime)<5)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 2";
        }
         else if (Velocity(accel,ntime) >=5 && Velocity(accel,ntime)<7)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 3";
        }
         else if (Velocity(accel,ntime) >=7 && Velocity(accel,ntime)<10)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 4";
        }
         else if (Velocity(accel,ntime) >=10 && Velocity(accel,ntime)<12)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 5";
        }

         else if (Velocity(accel,ntime) >=12 && Velocity(accel,ntime)<15)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 6";
        }
         else if (Velocity(accel,ntime) >=15 && Velocity(accel,ntime)<17)
        {
            cout<<"\nyour volcity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 7";
        }
         else if (Velocity(accel,ntime) >=17 && Velocity(accel,ntime)<21)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 8";
        }
         else if (Velocity(accel,ntime) >=21 && Velocity(accel,ntime)<24)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 9";
        }
         else if (Velocity(accel,ntime) >=24 && Velocity(accel,ntime)<28)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 10";
        }
         else if (Velocity(accel,ntime) >=28 && Velocity(accel,ntime)<35)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 11";
        }
         else if (Velocity(accel,ntime) >=35 && Velocity(accel,ntime)<40)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 12";
        }
         else if (Velocity(accel,ntime) >=40 && Velocity(accel,ntime)<48)
        {
            cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<" YOUR GEAR IS : 13";
        }
         else if (Velocity(accel,ntime) >=48 && Velocity(accel,ntime)<55)
        {
            cout<<"\nyour Velocity was   "<<Velocity(accel,ntime)<<endl;
           cout<<"YOUR GEAR IS : 14";
        }
         else if (Velocity(accel,ntime) >=55 && Velocity(accel,ntime)<100)
        {
           cout<<"\nYour Velocity was    "<<Velocity(accel,ntime)<<endl;
           cout<<"YOUR GEAR IS : 15";
        }
         else if (Velocity(accel,ntime) >100 )
        {
           cout<<" The Maximmum Volcity that the programme can calcluate is 100 km/hr... SORRY!";
        }
        else if (Velocity(accel,ntime) <0 )
        {
           cout<<" ERROR!!";
        }
        }
//------->end of if velocity

else// else for if time
{
cout<< "Your time is Invalid";
}
        cout<<"\n\nDo you wish to continue? (Y/N)";
		cin>>choice;
		cout<<"\n\n\n----------------------------\n\n\n";
        system("cls");
}while(choice == 'Y'|| choice == 'y');
return 0;
}



Last edited on
Multiple posts are not allowed... And I've given a suggestion at the original post... try it :)
okay i am just nervous ... because i need to submitted tomorrow morning .. and every minute there is something wrong came out .....i will stick in the original post.. thnx
Topic archived. No new replies allowed.