I have an Amusement Park Problem in C++
Category
Children
Price $2.00
The first child is always free
Category
Youth
Price
$8.50
For every 4 tickets in this group one person is free.
Buy 4,get one free
Category
Adult
Price $12.50
After 10 adult tickets,the price is $9.00 per ticket.
The first 10 tickets are always $12.50
I tried doing a double while statement but it didn't work.Could I have an hint for the buy 4 get 1 free and After 10 adult tickets,the price is $9.00 per ticket
Here is my code
// Author: Robert
// Source file: Project2.cpp
//Description: Fanzone Amusement Park
//Compiler: Microsoft Visual Studio.NET
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int number_of_Children_tickets = 0;
int number_of_free_Children_tickets = 0;
int number_of_Youth_tickets = 0;
int number_of_free_Youth_tickets = 0;
int number_of_Adult_tickets = 0;
int number_of_tickets = 0;
int total_number_of_Children_tickets = 0;
int total_number_of_Youth_tickets = 0;
int total_number_of_Adult_tickets = 0;
//double price_of_free_Youth_tickets = 0.00;
//double price_of_free_Children_tickets = 0.00;
double price_of_Children_tickets = 2.00;
double price_of_Youth_tickets = 8.50;
double price_of_Adult_tickets = 12.50;
double Total_of_Children_tickets = 0.0;
double Total_of_Youth_tickets = 0.0;
double Total_of_Adult_tickets = 0.0;
//double Total_of_free_Children_tickets;
//double Total_of_free_Youth_tickets;
double Total = 0.0;
int Total_Tickets = 0;
while (number_of_Children_tickets != -1)
{
cout << "Enter the number of Children tickets you would like to purchase and press enter.\n";
cin >> number_of_Children_tickets;
if (number_of_Children_tickets != -1)
{
total_number_of_Children_tickets += number_of_Children_tickets;
cout << "Enter the number of Youth tickets you would like to purchase and press enter.\n";
cin >> number_of_Youth_tickets;
total_number_of_Youth_tickets += number_of_Youth_tickets;
cout << "Enter the number of Adult tickets you would like to purchase and press enter.\n";
cin >> number_of_Adult_tickets;
total_number_of_Adult_tickets += number_of_Adult_tickets;
}
//cout << "Enter the number of free Childrens tickets you would like and press enter.\n";
//cin >> number_of_free_Children_tickets;
}
if (total_number_of_Children_tickets > 0)
{
number_of_free_Children_tickets = 1;
}
Total_of_Children_tickets = (price_of_Children_tickets * (total_number_of_Children_tickets - number_of_free_Children_tickets));
Total_of_Youth_tickets = (price_of_Youth_tickets * total_number_of_Youth_tickets - number_of_free_Children_tickets);
Total_of_Adult_tickets = (price_of_Adult_tickets * total_number_of_Adult_tickets);
Total = Total_of_Children_tickets - number_of_free_Children_tickets + Total_of_Youth_tickets + Total_of_Adult_tickets;
Total_Tickets = total_number_of_Children_tickets + total_number_of_Youth_tickets + total_number_of_Adult_tickets;
if ((Total_Tickets >= 20) || (total_number_of_Youth_tickets >= 8))
{
Total += 25.00;
}
cout << "Type of Ticket Tickets Price Total\n";
cout << "Children " << total_number_of_Children_tickets - number_of_free_Children_tickets << " " << price_of_Children_tickets << " " << Total_of_Children_tickets << "\n";
cout << "Youth " << total_number_of_Youth_tickets << " " << price_of_Youth_tickets << " " << Total_of_Youth_tickets << "\n";
cout << "Adult " << total_number_of_Adult_tickets << " " << price_of_Adult_tickets << " " << Total_of_Adult_tickets << "\n";
cout << "Free Children Tickets " << number_of_free_Children_tickets << " " << number_of_free_Children_tickets << "\n";
//cout << number_of_tickets << "Children_tickets\n";
//cout << number_of_tickets << " Youth_tickets\n";
//cout << number_of_tickets << " Adults_tickets\n";
cout << Total << " - Total\n";
cin >> number_of_Youth_tickets;
return 0;
}