How should I edit my C++ code below? It displays the incorrect math answer to the fare.
//PASSENGER’S FARE
#include using namespace std;int main(){float distance_km, fare;int passenger, vehicle, vehicle_opt;cout < "enter="" the="" distance="" in="" kilometers:="">cin >> distance_km;cout < "choose="" the="" type="" of="" vehicle:="" "=""><>cout<"1.>"1.><>cout<"2.>"2.><>cin >> vehicle;cout < "choose="" the="" type="" of="" passenger:="" "=""><>cout<"1.>"1.><>cout<"2.>"2.><>cout<"3.>"3.><>cout<"4. person="" with="">"4.><>cin >> passenger;switch(vehicle_opt){case 1:fare = 40 + 15*(distance_km - 1);break;case 2:if(passenger==1){fare = 7.50 + (1.15)*(distance_km - 4);}else{fare = 6.00 + (0.92)*(distance_km - 4);}break;}cout<>cout< "passenger's="" fare:="" "=""><>return 0;}Extracted text: Sy Lines is one of the most famous and trusted transportation vehicles in the region. They offer 2 types of vehicles that the commuters can choose: (1) Taxi and (2) Jeepney. The base fare for the taxi is Php 40.00 and additional Php 15 for each km. For the jeepney, the fare is Php 7.50 for the regular passengers and Php 6.00 for the students & senior citizen for the first 4km. Succeeding km will be charged Php 1.15/ km and Php 0.92/km respectively. Write a program that will compute and display the passengers fare given the distance (km) and the type of passenger (Regular & Student/Senior/PWD).
using namespace std;int main(){float distance_km, fare;int passenger, vehicle, vehicle_opt;
cout < "enter="" the="" distance="" in="" kilometers:="">cin >> distance_km;
cout < "choose="" the="" type="" of="" vehicle:="" "=""><>cout<"1.>"1.><>cout<"2.>"2.><>cin >> vehicle;cout < "choose="" the="" type="" of="" passenger:="" "=""><>cout<"1.>"1.><>cout<"2.>"2.><>cout<"3.>"3.><>cout<"4. person="" with="">"4.><>cin >> passenger;
switch(vehicle_opt){case 1:fare = 40 + 15*(distance_km - 1);
break;
case 2:if(passenger==1){fare = 7.50 + (1.15)*(distance_km - 4);}else{fare = 6.00 + (0.92)*(distance_km - 4);
}break;}cout<>cout< "passenger's="" fare:="" "=""><>
return 0;
}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here