Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

# include using namespace std;

const int base_cost_of_trip = 200;

int main()

{

int air;

int boat;

int train;

int numDays;

int standardPrice;

int premiumPrice;

int totalPrice;

//prompt

cout << "air/train/boat: ";

cin >> air, boat, train;

cout << endl;

cout << "Enter num days: ";

cin >> numDays;

cout << endl;

cout << "Enter standard/premium: ";

cin >> standardPrice, premiumPrice;

cout << endl; cout << "price: ";

cin >> totalPrice;

cout << endl;

return 0;

}

could someone please tell me if I am writing this code correctly? and how to do the math part please. with explanation please. THANK YOU

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions