In: Computer Science
Your program should select one of the above option. Once the option is selected then your program should select one of the following airlines:
Once the airline is selected then read number of passengers airfare for round trip. Calculate the total charge.
make your own charges
Below is the solution:
#include <iostream>
using namespace std;
int main() {
string summerVacation,airlines;
int
vacationOption,airlinesOption,noOfPassengers;
float flightcharge,km;
cout<<"1. Hawaii\n2. Bahamas\n3. Cancun Las\n4.
Vegas Europe\n";
cout<<"Enter an option for summer vacation
type:";
cin>>vacationOption; //accept the input of
vaction type
switch(vacationOption){
case 1: summerVacation =
"Hawaii";
km=200;
break;
case 2: summerVacation =
"Bahamas";
km=243;
break;
case 3: summerVacation = "Cancun
Las";
km=300;
break;
case 4: summerVacation = "Vegas
Europe";
km=570;
break;
default: summerVacation = "invalid
vacation choice";
km=0;
break;
}
cout<<"\n1. US Air\n2. Delta\n3. Southwest\n4.
Continental\n4. American Airline\n";
cout<<"Enter an option for Airlines
type:";
cin>>airlinesOption; //accept the input of
airlines type
switch(airlinesOption){
case 1: airlines = "US Air";
flightcharge = 2; //per kilometer
break;
case 2: airlines = "Delta";
flightcharge = 2.5; //per kilometer
break;
case 3: airlines =
"Southwest";
flightcharge = 2.1; //per kilometer
break;
case 4: airlines =
"Continental";
flightcharge = 3.3; //per kilometer
break;
case 5: airlines = "American
Airline";
flightcharge = 4.1; //per kilometer
break;
default: airlines = "invalid
airlines choice";
flightcharge = 0; //per kilometer
break;
}
cout<<"\nEnter the number of passengers airfare
for round trip:";
cin>>noOfPassengers; //accept the no of
passenger to travel
float totalFare =
(flightcharge*km)*noOfPassengers; //calculate the flight charge by
flight fare * kilometer travel * no of passenger
//display the info and flight charge total
cout<<"\nSummer Vacation is:
"<<summerVacation<<endl;
cout<<"Airlines is:
"<<airlines<<endl;
cout<<"Total fare is:
"<<totalFare<<endl;
return 0;
}
sample output:
1. Hawaii 2. Bahamas 3. Cancun Las 4. Vegas Europe Enter an option for summer vacation type: 2 1. US Air 2. Delta 3. Southwest 4. Continental 4. American Airline Enter an option for Airlines type: 2 Enter the number of passengers airfare for round trip: 4 Summer Vacation is: Bahamas Airlines is: Delta Total fare is: 2430
If found the solution helpful please upvote.