#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