#include <iostream>
using namespace std;

int main()
{
   int speed,      
       time,  
       distance;     

   // Get the speed.
   cout << "What is the speed of the vehicle in mph?\n";
   cout << "(Enter a value greater than 0): ";
   cin >> speed;
   
   // Validate the input.
   while (speed < 0)
   {
      cout << "Please re enter the speed greater than 0\n";
      cout << "What is the speed of the vehicle in mph? ";
      cin >> speed;
   }
   
   // Get the hours available.
   cout << "How many hours has it traveled? ";
   cin >> time;
   
   // Validate the input.
   while (time < 1)
   {
      cout << "Please enter a positive number higher than 1 ";
      cin >> time;
   }

   // Calculate the distance.
   distance = speed * time;
   
   
   
   // Display the results.
   cout << time << "\t \t" <<  distance << endl;
   system ("pause");
   return 0;
}

If your enter 40 mph(speed) and 3 hours(time) your answer comes out to be:
3 120
I need the results to look like this:
1 40
2 80
3 120

Please help me out need help this is a lab! ty much appreciated

Well if you want to break it up for every hour you will need a loop

for (int i = 1; i <= time; i++){
   cout << time << time * speed << endl;
  }

k thank you very much
such a quick response too thank you i'll will try to finish it

where should i put that i tried it at the end but doesn't quite work and tried it under the hours. srry i am really dumb

please someone help where do i place that code? that guy gave me

Put it here

for (int hour = 1; hour <= time; hour++){
   // Calculate the distance.
   distance = speed * hour;
  // Display the results.
   cout << time << "\t \t" <<  distance << endl;
}

   system ("pause");
   return 0;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.