My code only outputs 0.00 when 'y' is entered. Clearly, I'm a beginner.
#include <iostream>
#include <iomanip>
#include <string>
const double ADULTFEE = 18.00, CHILDFEE = 7.50, TRAINFEE = 6.00, BIRDFEE = 5.00;
using namespace std;
int main ()
{
char reply = ' ';
double adultNum = 0, childNum = 0, guestAdult = 0, guestChild = 0, trainNum = 0, birdNum = 0;
double totalFee = 0;
cout << "Welcome to Jake's Fee Calculator" << endl;
cout << "How many adults (age 14 or over) are in your party? ";
cin >> adultNum;
cout << "How many children (age 5 to 13) are in your party? ";
cin >> childNum;
cout << "Do you have a family membership? (y/n) ";
cin >> reply;
if (tolower(reply) == 'y')
{
cout << "How many adults in your party are guests? ";
cin >> guestAdult;
cout << "How many children (age 5 to 13) in your party are guests? ";
cin >> guestChild;
cout << "How many train tickets would you like? ";
cin >> trainNum;
cout << "How many bird show tickets would you like? ";
cin >> birdNum;
}
else
{
cout << "How many train tickets would you like? ";
cin >> trainNum;
cout << "How many bird show tickets would you like? ";
cin >> birdNum;
}
if (reply == 'y' && guestAdult > 2)
totalFee = ((guestAdult - 2) * ADULTFEE) + (guestChild * CHILDFEE) + (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && guestAdult == 2)
totalFee = (guestChild * CHILDFEE) + (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && (guestAdult == 1 && guestChild == 0))
totalFee = (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && (guestAdult == 1 && guestChild == 1))
totalFee = (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && (guestAdult == 0 && guestChild == 2))
totalFee = (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && (guestAdult == 0 && guestChild > 2))
totalFee = ((guestChild - 2) * CHILDFEE) + (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'y' && (guestAdult == 0 && guestChild == 1))
totalFee = (((trainNum * TRAINFEE) + (birdNum * BIRDFEE))/2);
else if (reply == 'n')
totalFee = (adultNum * ADULTFEE) + (childNum * CHILDFEE) + (trainNum * TRAINFEE) + (birdNum * BIRDFEE);
cout << fixed << showpoint;
cout << setprecision(2);
cout << "Your total fee is $" << totalFee << endl;
cout << "Thank you for using Jakes's Fee Calculator" << endl;
system("pause");
}