CAN YOU CHECK MY assignment PLZZ

Pages: 12
ooh right .. now i can input the time but still give me invalid time when i tried to put as hh:mm:ss
1
2
3
4
5
6
7
8
if (h>=0&&m>=0&&s>=0&&h<24&&m<=60&&s<=60)
{
   //the code
}
else
{
cout<<"invalid time";
}
Hmm... Check your entire code just once to check for any logical errors. Just use pastebin and give the link, so I can also have a clean look at it.. we'll figure it out.. :)
http://pastebin.com/HwRZDayC

i am working in this code for about 5 hours if you find any logical error am going to kill my self

just to know there is two if -statement
1
2
3
4
5
6
7
8
9
10
if (h>=0&&m>=0&&s>=0&&h<24&&m<=60&&s<=60)
{
   
//the code
// if-statement for velocity function 
}
else
{
cout<<"invalid time";
}



Last edited on
Ohk, this is not the solution, but just as a by-the-by... line 72 is redundant, it does absolutely nothing. Also, assign Velocity(accel, ntime) to some variable, and then use the variable in your if and else loops. Calling a function 33 times in a program? Not very efficient.

EDIT1: Line 75 has an error. You're displaying Velocity. What is Velocity? you need to output Velocity(accel, ntime) (or use my above suggestion and display the variable). YOu've output correctly in the rest of the loops...

EDIT 2: Maybe ne555 was right... try using fgets() instead of gets()...

EDIT 3: Try this. After you've calculated values of h, m and s, just output them once. See if they satisfy the conditions in the time if loop. if they do, there is a logical error somewhere that we'll figure out, and if they don't then change the calcs...
Last edited on
i think the problem cause by gets()

i write simple programme that contains only this time and calculate the velocity directly
and we have the same problem ... ??!

how i use fgets ??




1101109758
Last edited on
Hmm... Try keeping the time in seconds... maybe the double type of data is nt working.. ? Have u tried using simple int? coz ders no need fr double in ur program...
Topic archived. No new replies allowed.
Pages: 12