Hi, basically I am working on a program and I seem to be getting a very annoying bug which I am strugulling with. It wont print the total price for each person.
Here is my code below:
#include <iostream>
#include <string>
using namespace std;
int main () {
string staffName;
string movieName1 = “Deadpool”;
string movieName2 = “Goosebumps”;
string movieSelected;
cout << “Hi and Welcome to the Cinema Ticket Generator” << endl;
cout << "Please enter your name: " << endl;
cin >> staffName;
cout << "Welcome to the program " << staffName << endl;
cout << “There are two movies available to watch in the Cinema today” << endl;
cout << “Which movie would you like to watch " << movieName1 << " or " << movieName2 <<”: " << endl;
cin >> movieSelected;
float adultRate = 10.30;
float seniorRate = 20/100 * adultRate;
float calculatedSeniorRate = adultRate - seniorRate;
float childrenRate = 50/100 * adultRate;
int adult = 0;
int senior = 0;
int children = 0;
float totaladultPrice = adultRate * adult;
float totalSeniorPrice = calculatedSeniorRate * senior;
float totalChildrenPrice = childrenRate * children;
double ticketTotalPrice = totaladultPrice + totalSeniorPrice + totalChildrenPrice;
if (movieSelected == movieName1) {
cout << "How many Adults are there: ";
cin >> adult;
cout << "How many Senior are there: " << endl;
cin >> senior;
cout << "How many Children are there: " << endl;
cin >> children;
cout << "The total price for Adults is: " << totaladultPrice << endl;
cout << "The total price for Senior is: " << totalSeniorPrice << endl;
cout << "The total price for Children is: " << totalChildrenPrice << endl;
cout << "The Ticket is being printed: " << endl;
cout << movieName1 << endl;
cout << adult << ": " <<totaladultPrice << endl;
cout << senior << ": " << totalSeniorPrice << endl;
cout << children << ": " << totalChildrenPrice << endl;
cout << ticketTotalPrice << endl;
} else {
cout << "How many Adults are there: " << endl;
cin >> adult;
cout << "How many Senior are there: " << endl;
cin >> senior;
cout << "How many Children are there: " << endl;
cin >> children;
cout << "The total price for Adults is: " << totaladultPrice << endl;
cout << "The total price for Senior is: " << totalSeniorPrice << endl;
cout << "The total price for Children is: " << totalChildrenPrice << endl;
cout << "The Ticket is being printed: " << endl;
cout << movieName2 << endl;
cout << adult << ": " << totaladultPrice << endl;
cout << senior << ": " << totalSeniorPrice << endl;
cout << children << ": " << totalChildrenPrice << endl;
cout << ticketTotalPrice << endl;
}
cout << "Enjoy your movie!! " << endl;
return 0;
}
Please Help me I am really stuck and I cant seem to fix it.
Thanks