Question

Write a do-while loop for a ticket-taker to determine the price for a ticket.

The base price is $25.00, but people 55 and over get a $5.00 discount. Children under 10 years old get a $6.50 discount, and children under 5 are free.

Declare constants, and use them in your code, not hard-coded numbers.

You must calculate the price, not just have code that says the ticket is 20.00.

Format output with 2 decimal places.

After selling each ticket, ask if you want to sell another ticket (Y/N)? If Y, run the loop again, if not, exit your program with a message such as: Good Bye.

Sample output:

What is age of ticket buyer? 32

The ticket is 25.00

Do you want to sell another ticket (Y/N)? Y

What is the age of ticket buyer? 59

The ticket is 20.00

Do you want to sell another ticket (Y/N)? Y

What is the age of ticket buyer? 6

The ticket is 18.50

Do you want to sell another ticket (Y/N)? Y

What is the age of ticket buyer? 4

The ticket is free

Do you want to sell another ticket (Y/N)? N

Good Bye

(for the output the ticket has to say free not 0)

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>

#define NORMALPRICE 25.00
#define SENIORPRICE 20.00
#define UNDERTEN 18.50

using namespace std;

int main()
{
    int age;
    char exit;
    do
    {
   cout << "Please enter the age of the ticket buyer: ";
   cin >> age;

   if(age < 0)
cout << "Incorrect age, please try again" << endl;
   else if( age < 5)
cout << "The ticket is free" << endl;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Contact List Program in C++
Homework Solution
$18.00
Computer Science
Programming
Contact List
C++
Phone Numbers
Classes
Constructors
Member Variables
Strings
Pointers
Names
People
Test Values
Menu
Functions
Print
Search
Add
Delete
Arrays in Programming Language C
Homework Solution
$30.00
Programming
C-Family
Computer Science
Arrays
Rows
Columns
Pairs
Functions
Pass by Address
Pass by Reference
Characters
Input
Output
Display
Loops
Conditions
Get help from a qualified tutor
Live Chats