QuestionQuestion

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 PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use 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;...

By purchasing this solution you'll be able to access the following files:
Solution.cpp.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats