76 297
Assignments Done
Successfully Done
In May 2019

Answer to Question #19049 in C++ for mhamad

Question #19049
this program accept the following:
1. 5 type of car (a,b,c,d,f)
2.for each it accept the length of the car in centimeter
3.the length of the road in kilometer
4.the number of the lanes in the road
5.if the road is double-side or not

the program then calculates that how many of cars can fit on the road. the program assume 2 meters distance between each tow consecutive cars. the program also assume that there would be exactly 20% of each ace type on the road
Expert's answer
# include <iostream>

using namespace std;

int main(){
int car[5];
double road;
int num;
bool size;
char c;
for(int i=0;i<5;i++){
cout<<"Enter size of car "<<i<<endl;

cout<<"Enter km of road"<<endl;
cout<<"Enter num of lanes "<<endl;
cout<<"Road is double-sized? (y/n) "<<endl;
if ((c=='y')||(c=='Y')) {size=1; num*=2;}
else size=0;

int am=static_cast <int> (num*road*1000/(((2+car[0])+(2+car[1])+(2+car[2])+(2+car[3])+(2+car[4]))));
& cout<<"MAX amount of each car is "<<am<<endl;

return 0;

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions