Hey everyone, I'm fairly new to C++ and have been given an assignment for my class. My professor isn't that good at explaining the material so I'm a bit lost. The prompt I have is to enter destinations and passengers into the command line "FileName Location Passengers Passenger_Number" so for example "Travel MIAMI Passengers 5". This will in turn notify me of the price to fly to each destination depending on the location and the number of passengers. The requirements are:
1. You can have a maximum of 5 locations, and a minimum of 1.
2. Passengers input is required. At least 1. No maximum.
3. If any location codes are unknown, please exit the application
I have everything running the way it should, the only problem I am encountering, is the max and min of the locations. For example, I can get "FileName Location Location Location Location Location Passengers PassengerNumber" to work, however I don't know how to make it work if I only input 1-4 locations rather than 5. I was told I have to create a for loop? Does anyone know how I can apply this to my assignment?
yeah, so the above is what my assignment looks like so far. to correct my current issue, I tried to do a for function for every if functions. so
for(int i = 0; i < 8; i++){
while (direction1){
if(input1 == "MIAMI" || input1 == "Miami"){
direction1 = false;
location[1] = 250;
}else if(input1 == "HAWAII" || input1 == "Hawaii"){
direction1 = false;
location[1] = 300;
}else if(input1 == "LA"){
direction1 = false;
location[1] = 200;
}else if(input1 == "NY"){
direction1 = false;
location[1] = 275;
}else if(input1 == "SEATTLE" || input1 == "Seattle"){
direction1 = false;
location[1] = 280;
}else{
cout << "I'm sorry, but you have input an invalid location. Please check your spelling, and try again" << endl;
return 0;
}
}
and then for the next if function I would just do for(int i = 0; i < 7; i++)
and keep doing that till I got to i < 4 and stopped
Assignment:
LinAppleSoft has received a contract for a travel agency. They've asked for an itinerary application to price out travel plans for new customers.
Create an application that does the following:
receives a list of location code inputs in the command line
receives a passenger count in the command line
tallies up the flight plan cost
applies taxes
asks for a coupon code. If LINAPPLESOFT in given, and applies a 10% discount
Command line input should be formatted like this:
====================================
Output:
The client is picky. Output should look EXACTLY like the following:
> TravelAgent MIAMI HAWAII Passengers 4
Greetings! Thank you for choosing LinAppleSoft Travel. You have chosen the following locations:
Location: Miami - $250
Location: Hawaii - $300
Number of tickets: 4
====================================
Pricing:
Location
Location Code
Price
Miami
MIAMI
$250
Hawaii
HAWAII
$300
Los Angeles
LA
$200
New York
NY
$275
Seattle
SEATTLE
$280
Ticket total: sum of all ticket prices * passenger count
Fees: 10% of Ticket total
Subtotal: Fees + ticket total.
Discount: 10% of subtotal
Taxes: 15% of (subtotal - discount)
Total price: subtotal - discount + taxes
Revised total: total price - discount.
====================================
Requirements:
1. You can have a maximum of 5 locations, and a minimum of 1.
2. Passengers input is required. At least 1. No maximum.
3. If any location codes are unknown, please exit the application.
====================================
HINTS:
1. Passenger count will always be the last input on the command line.
2. Given the command line input format, the location list on the command line will always be from index[1] to index [parameterCount - 3];