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
1
Expert's answer
2012-11-20T08:10:46-0500
# 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; cin>>car[i];}
cout<<"Enter km of road"<<endl; cin>>road; cout<<"Enter num of lanes "<<endl; cin>>num; cout<<"Road is double-sized? (y/n) "<<endl; cin>>c; 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;
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment