I need a C++ program that asks the user for the speed of a vehicle (in mph) and
ID: 3624454 • Letter: I
Question
I need a C++ program that asks the user for the speed of a vehicle (in mph) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle traveled for each hour of that time period.Example of output:
What is the speed of the vehicle in mph? 40
How many hours has it traveled? 3
Hours Distance traveled
----------------------------------
1 40
2 80
3 120
It cannot accept a negative number for speed or value less than 1 for time traveled.
Thanks for any help
Explanation / Answer
#include using namespace std; int main() { int speed = -1; int time = 0; while (speed < 0 || time < 1) { cout > speed; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.