有人能指出我正确的方向,所以车辆类接受选项,例如巴士。 进入车辆类时,结果总是,未知的车辆类!
#include <iostream>
using namespace std;
int main()
{
int vehicleClass;
double toll;
cout << "Enter vehicle class. E.g.: Passenger car. Bus. Truck.: ";
cin >> vehicleClass;
switch (vehicleClass)
{
case 1:
cout << "Passenger car.";
toll = 0.50;
break;
case 2:
cout << "Bus.";
toll = 1.50;
break;
case 3:
cout << "Truck.";
toll = 2.00;
break;
default:
cout << "Unknown vehicle class!";
}
}
// Running doesn't work when you enter a vehicle class.