Question #279494

An automobile travels at an average speed of 55 miles per hour for four hours. Draw a flowchart, write an algorithm and design a C++ program that displays the distance driven, in miles that the car has traveled after 0.5 1.0, 1.5 hours, and so on until the end of the trip.


Expert's answer

The program:

#include<iostream>
using namespace std;
int main(){
double speed = 55;


double hours = 4;


double distance = 0;


double i = 0.5;
while(i<=hours){
	distance = distance + (speed / 2);
	cout<<i<<endl;
	cout<<"Distance:  "<<distance<<endl;
	i += 0.5;
	
}


}




The Flowchart:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS