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: " << "\n"; cout<<"1. Taxi"<<"\n"; cout<<"2. Jeepney"<<"\n"; cin >> vehicle; cout << "Choose the type of passenger: " << "\n"; cout<<"1. Regular"<<"\n"; cout<<"2. Student"<<"\n"; cout<<"3. Senior"<<"\n"; cout<<"4. Person with Disability"<<"\n"; 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<<"-------------------------------\n"; cout<< "Passenger's Fare: " <
How should I edit my C++ code below? It displays the incorrect math answer to the fare.
//PASSENGER’S FARE
#include <iostream>
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: " << "\n";
cout<<"1. Taxi"<<"\n";
cout<<"2. Jeepney"<<"\n";
cin >> vehicle;
cout << "Choose the type of passenger: " << "\n";
cout<<"1. Regular"<<"\n";
cout<<"2. Student"<<"\n";
cout<<"3. Senior"<<"\n";
cout<<"4. Person with Disability"<<"\n";
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<<"-------------------------------\n";
cout<< "Passenger's Fare: " <<fare;
return 0;
}
![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).](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F74f7ae45-f0e3-44d2-9ad1-30211498e68b%2Fa74cbeba-3444-45d7-9f5a-9666600a6cac%2Fut0krlv_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)