Hello everyone.
I am having a hard time getting this program to run w/o an infinite loop. I have been in my C++ class for a month. I think my test expression is incorrect, but I've tried what I think it should be.
Problem:
Write a program that asks the user for the speed and hours traveled. The program should use a loop to display the distance for each hour of that time period. Here's my code:
double distance, mph, hours;
cout << " What is the speed of the vehicle in MPH? ";
cin >> mph;
cout << " How many hours has it traveled? ";
cin >> hours;
for (hours =1; hours = 0; hours += mph)
distance = mph * hours;
cout << " (display the table: 1 40
2 80
3 120)
cout << hours << "\t\t" << distance << endl;