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: " <

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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).
Transcribed Image 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).
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY