Hello, I have been assigned to write a program that takes users imputs and calcu
ID: 671087 • Letter: H
Question
Hello,
I have been assigned to write a program that takes users imputs and calculates the fee for their trip. here is waht I have so far:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
char reply;
double numAdults;
double numChildren;
char fMembership;
double trainTickets;
double birdTickets;
double totalPrice;
double adultTotal;
double childTotal;
double adultGuests;
double childGuests;
const double adultPrice = 18.00;
const double childPrice = 7.50;
const double trainPrice = 6.00;
const double birdPrice = 5.00;
cout << "Welcome to Austin Whittaker's Fee Calculator " << endl;
cout << "How many adults (age 14 or over) are in your party? ";
cin >> numAdults;
cout << "How many children (age 5 to 13) are in your party? ";
cin >> numChildren;
cout << "Do you have a family membership? (y/n): ";
cin >> fMembership;
if (fMembership == 'y' || fMembership == 'Y') {
cout << "How many adults in your party are guests? ";
cin >> adultGuests;
cout << "How many children (age 5 to 13) in your party are guests? ";
cin >> childGuests;
if (adultGuests > 2) {
adultTotal = (adultGuests - 2) * adultPrice;
childTotal = childGuests * childPrice;
}
else {
adultTotal = 0;
childTotal = 0;
}
cout << "How many train tickets would you like? ";
cin >> trainTickets;
cout << "How many bird show tickets would you like? ";
cin >> birdTickets;
totalPrice = adultTotal + childTotal + (trainTickets * (.5 * trainPrice)) + (birdTickets * (.5 * birdPrice));
}
else if (fMembership == 'n' || fMembership == 'N');
{
cout << "How many train tickets would you like? ";
cin >> trainTickets;
cout << "How many bird show tickets would you like? ";
cin >> birdTickets;
totalPrice = (numAdults * adultPrice) + (numChildren * childPrice) + (trainTickets * trainPrice) + (birdTickets * birdPrice);
}
cout << "Your total fee is $" << totalPrice << endl;
cout << "Thank you for using Austin Whittaker's Fee Calculator" << endl;
system("pause");
}
My question is when it compiles it asks
"How many train tickets would you like? ";
cin >> trainTickets;
cout << "How many bird show tickets would you like? ";
cin >> birdTickets;
Twice. I cant figure out how to fix it.
Our example says it should look like the following with the bold as the users imputs:
Example #1
Welcome to John Doe’s Fee Calculator
How many adults (age 14 or over) are in your party? 3
How many children (age 5 to 13) are in your party? 1
Do you have a family membership? (y/n): n
How many train tickets would you like? 4
How many bird show tickets would you like? 2
Your total fee is $95.50
Thank you for using John Doe’s Fee Calculator
Example #2
Welcome to John Doe’s Fee Calculator
How many adults (age 14 or over) are in your party? 3
How many children (age 5 to 13) are in your party? 5
Do you have a family membership? (y/n): y
How many adults in your party are guests? 1
How many children (age 5 to 13) in your party are guests? 3
How many train tickets would you like? 0
How many bird show tickets would you like? 2
Your total fee is $20.00
Thank you for using John Doe’s Fee Calculator
Explanation / Answer
else if (fMembership == 'n' || fMembership == 'N');
Remove the semicolon at the end of else if statement.
else if (fMembership == 'n' || fMembership == 'N')
{
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.