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
# 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started