Help Simple program

Im suppose to create a program in which i ask user for MPH and time traveled.
For example, if a train travels 40 miles-per-hour for three hours, the distance traveled is 120 miles. and display.
Hour Distance Traveled
1 40
2 80
3 120


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      double vs; // vehicle speed 
      double hours; 
      double S_H;
    
      cout << " Enter the speed of the vehicle (MPH): " << endl;
      cin >> vs;

      cout << "Enter the period of time the vehicle has traveled (hours): " << endl;
      cin >> hours;

      S_H = hours * vs
      
       int i; 
       for (i = vs; i < S_H; i++)
         {
               cout << "Hours   Distance Travalled" << endl;
              cout << i << " " <<endl;
         }



Last edited on
Listen to your compiler dude :)

Mine's saying this:
(18): error C2144: syntax error : 'int' should be preceded by ';'


I.e. on line 18 (in my ide) i'm missing a ';'.

That's hinting at line 11 in your program.



edit: Then you want to sort out your print statement and your logic :)
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
      double vs; // vehicle speed 
      double hours; 
      double S_H;
    
      cout << " Enter the speed of the vehicle (MPH): " << endl;
      cin >> vs;

      cout << "Enter the period of time the vehicle has traveled (hours): " << endl;
      cin >> hours;

      S_H = hours * vs ; //<----
      
       int i; 
       for (i = vs; i < S_H; i++)
         {
               cout << "Hours   Distance Travalled" << endl;
              cout << i << " " <<endl;
         }
Topic archived. No new replies allowed.