Question

Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The...

Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The charge for an adult meal is $6.00 and a child’s (ages 5 to 10) meal is $3.00. The tax rate is 6.5%. The desserts offered at the restaurant are slices of pie at $1.00 per slice. Gratuity is automatically calculated at 15%. Use main( ) as the driver function. Allow the user to process as many customer bills as desired. Use named constants and perform input validation when appropriate.

a. Write one function to prompt the user for the following customer information:

• Date of the bill.

• Customer’s Name.

• Number of Adult Meals.

• Number of Child Meals.

• Number of Desserts.

b. Write one function to calculate all charges necessary for the customer’s bill as displayed below.

c. Write one function to display the customer’s bill using the following information: the date, the Customer’s Name, Number of Adult Meals and charge, Number of Child Meals and charge, Dessert Charge, Taxes, Subtotal, Gratuity (Tip) Charge, and Total Charges.

Sample I/O:

Please enter the following Customer's Information.

Date: 4-6-05

Customer's Name: The Bill Jones Family

Number of Adult Meals: 2

Number of Child Meals: 3

Number of Desserts: 5

The All-You-Can-Eat Buffet Restaurant

Date: 4-6-05

Customer's Name: The Bill Jones Family

Adult Meal Charge: 2 @ 6.00 each $ 12.00

Child Meal Charge: 3 @ 3.00 each $ 9.00

Dessert Charge: 5 @ 1.00 each $ 5.00

Taxes $ 1.69

Subtotal: $ 27.69

Gratuity Charge: ( 15.00 %) $ 4.15

TOTAL DUE: $ 31.84

Thank you for eating at the All-You-Can-Eat Buffet Restaurant. Please come again.

Would you like to process another customer's bill? (Y or N) N


C++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ code

#include <iostream>

#include <string>

using namespace std;

void input(string &date ,string &name,int &adult,int &child, int &desserts ){ //input funtion use value by refrence

cout<<"Please enter the following Customer's Information."<<endl;

cout<<"Date: ";

getline(cin,date);

cout<<"Customer's Name: ";

getline(cin,name);

cout<<" Number of Adult Meals: ";

cin>>adult;

cout<<"Number of Child Meals: ";

cin>>child;

cout<<"Number of Desserts: ";

cin>>desserts;

}

void calculate(int adult,int child, int desserts,double &tax,double &sub,double &gratuity,double &total){

const int gratuityPer=15;

const int adultprice=6;

const int childpri=3;

const double taxPer=6.5;

sub=(adult*adultprice)+(child*childpri)+(desserts); //sub total

tax=(sub*taxPer)/100.0;//computing tax


sub+=tax; //sub total with tax


gratuity=(sub*gratuityPer)/100.0; //tip

total=sub+gratuity; //grand total

}

void output(string date,string name,int adult,int child,int desserts,double tax,double sub,double gratuity,double total){ //printing output

cout<<"The All-You-Can-Eat Buffet Restaurant\n";

cout<<"Date: "<<date<<endl;

cout<<"Customer's Name: "<<name<<endl;

cout<<"Adult Meal Charge: "<<adult<<" @ 6.00 each $ "<<(adult*6)<<endl;

cout<<"Child Meal Charge: "<<child<<" @ 3.00 each $ "<<(child*3)<<endl;

cout<<"Dessert Charge: "<<desserts<<" @ 1.00 each $ "<<desserts<<endl;

cout<<"Taxes $ "<<tax<<endl;

cout<<"Subtotal: $ "<<sub<<endl;

cout<<"Gratuity Charge: ( 15.00 %) $ "<<gratuity<<endl;

cout<<"TOTAL DUE: $ "<<total<<endl;

cout<<"Thank you for eating at the All-You-Can-Eat Buffet Restaurant. Please come again."<<endl;

}

int main() {

string date ,name;

int adult,child,desserts;

double tax,sub, gratuity,total,childC,adultC,dessertsC;

char ch;

do{

input(date,name,adult,child,desserts);

calculate( adult, child, desserts,tax, sub,gratuity,total);

output( date, name, adult, child, desserts, tax, sub, gratuity, total);

cout<<"Would you like to process another customer's bill? (Y or N) ";

cin>>ch;

}while(ch=='Y');

return 0;

}

OUTPUT:

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW

PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT