Answer to Question #295890 in C++ for Nickname

Question #295890

You are hired by an ice-skating center. Your job is to write a program to do calculate the admission fees as follows: 

• Children 6 and younger $8.50

• Children 7 and older. $10.50

• Adults $12.00

• Seniors $9.50


There will be 10% tax. PNG students, staff, and faculty will receive 25% discount (before tax).


Design an algorithm and write a C++ program that prompts the user to input the number of tickets in each group age and if the user is a student, staff, or faculty at PNG. The program calculates and outputs the admission fees as illustrated in the sample runs.


Output:

Are you PNG student, staff, or faculty?

Enter Y for yes or enter N for no: Y

Enter the number of children 6 and younger : 1

Enter the number of children 7 and older : 1

Enter the number of adults : 1

Enter the number of seniors : 1


  ******You received %25 Discount*****


Subtotal ......$30.38

Tax ...........$3.04

Total .........$33.41




1
Expert's answer
2022-02-10T02:49:54-0500

Algorithm:

  1. Input data
  2. Calculate subtotal
  3. If the discount is applied calculate the discount and print a message
  4. Calculate tax
  5. Calculate the total
  6. Print a bill


The program:

#include <iostream>
#include <iomanip>
using namespace std;


int main() {
    const double CHLD6 = 8.50;
    const double CHLD7 = 10.50;
    const double ADULT = 12.00;
    const double SENIOR = 9.50;
    const int PNG_DISCOUNT = 25;
    const int TAX = 10;
    int chld6, chld7, adults, seniors;
    bool isPNG;
    char ans;
    double subtotal, tax, total;


    cout << "Are you PNG student, staff, or faculty?" << endl;
    cout << "Enter Y for yes or enter N for no: ";
    ans = cin.get();
    if (ans == 'y' || ans == 'Y') {
        isPNG = true;
    }
    else {
        isPNG = false;
    }


    cout << "Enter the number of children 6 and younger : ";
    cin >> chld6;


    cout << "Enter the number of children 7 and older : ";
    cin >> chld7;


    cout << "Enter the number of adults : ";
    cin >> adults;


    cout << "Enter the number of seniors : ";
    cin >> seniors;


    cout << endl;
    subtotal = chld6*CHLD6 + chld7*CHLD7 + adults*ADULT + seniors*SENIOR;
    if (isPNG) {
        cout << " ******You received %" << PNG_DISCOUNT << " Discount*****" 
             << endl << endl;
        subtotal *= (1 - PNG_DISCOUNT/100.0);
    }


    tax = subtotal * TAX/100.0;
    total = subtotal + tax;


    cout << fixed;
    cout << "Subtotal ......$" << setprecision(2) << subtotal << endl;
    cout << "Tax ...........$" << setprecision(2) << tax << endl;
    cout << "Total .........$" << setprecision(2) << total << endl;

    return 0;
  }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog