Question: Write a C++ program to calculate the cost of a trip The user will enter the way to travel (air, train, or boat), the length

Write a C++ program to calculate the cost of a trip

The user will enter the way to travel (air, train, or boat), the length (days) of the trip, and if they are traveling in a standard or premium mode

The base cost of the trip is $200

Traveling by the train or boat is included in the base price. Traveling by air costs an additional $150

The first 2 days are included in the base price. Each day over 2, costs an additional $100

Standard travel is included in the base price. Premium travel costs an additional $75

Sample Run #1 (bold, underlined text is what the user types):

Enter air/train/boat: boat Enter num days: 4 Enter standard/premium: standard Price: $400

Here is an answer I received.

#include

using namespace std;

const int base_cost_of_trip = 200; // Base cost of the trip is constant and set to $200

const int air_additional_cost = 150; // Additional cost of traveling by air

const int daily_additional_cost = 100; // Additional cost per day over 2 days

const int premium_additional_cost = 75; // Additional cost of premium travel

int main() {

int modeOfTravel; // Variable to store the mode of travel (air, train, or boat)

int numDays; // Variable to store the number of days of the trip

int typeOfTravel; // Variable to store the type of travel (standard or premium)

int totalCost; // Variable to store the total cost of the trip

// Prompt the user to enter the mode of travel

cout

cin >> modeOfTravel;

// Prompt the user to enter the number of days of the trip

cout

cin >> numDays;

// Prompt the user to enter the type of travel

cout

cin >> typeOfTravel;

// Initialize the total cost with the base cost of the trip

totalCost = base_cost_of_trip;

// Add additional cost for traveling by air

if (modeOfTravel == 1) {

totalCost += air_additional_cost;

}

// Add additional cost for each day over 2 days

if (numDays > 2) {

totalCost += daily_additional_cost * (numDays - 2);

}

// Add additional cost for premium travel

if (typeOfTravel == 2) {

totalCost += premium_additional_cost;

}

// Display the total cost of the trip

cout

return 0;

}

When I run the Test Program, I am getting these errors. The Program work as asked but I can not figure what is needed to be changed so when I type air or boat or train. and be able to to chose standard cost or premium cost. please help explain what the changes where and why it was changed in that way.

THANK YOU

Write a C++ program to calculate the cost of a trip The

Mini Test 2 (Sample1_Cost) -> FAIL =0% Search For: $400 Input: Your Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!