0

Challenge

Write a program to calculate the parking charges of a vehicle. Enter the type of vehicle as character ( like c for car, b for bus, etc.) and number of hours then calculate the charges as given below: Truck/Bus---- $5 /hour Car-------$2/Hour Two wheeler------$.50/hour

12th Nov 2017, 7:21 AM
Victoria Kim
Victoria  Kim - avatar
2 Answers
+ 3
.
12th Nov 2017, 7:37 AM
᠌᠌Code X
᠌᠌Code X - avatar
0
#include <iostream> using namespace std; int main() { // your code goes here /* Challenge Write a program to calculate the parking charges of a vehicle. Enter the type of vehicle as character ( like c for car, b for bus, etc.) and number of hours then calculate the charges as given below: Truck/Bus---- $5 /hour Car-------$2/Hour Two wheeler------$.50/hour */ char vehi; int number; float pernumber; cout<<"Type of vehicle: "<<endl <<"c for car, b for bus, t for truck, 2 for two wheeler"<<endl; cin>>vehi; cout<<"Number of parking hour"<<endl; cin>>number; bool ok=true; switch(vehi){ case 'c' : pernumber=2;break; case 'b' : //the same as next case 't' : pernumber=5;break; case '2': pernumber=0.5; break; default: ok=false; } if (!ok) cout<<"There is not such vehicle parking sugested<<endl"; else cout<<"The the parking charges of your vehicle : "<<number*pernumber<<endl; return 0; } https://code.sololearn.com/cjZ3RnU2a9hu/#
12th Nov 2017, 8:42 AM
Petr Hatina
Petr Hatina - avatar