Question

When you go to a restaurant you need to calculate the tip that you need to...

When you go to a restaurant you need to calculate the tip that you need to give the waiter. Write a program that allows a user to enter the total bill, and whether g-good service, a-all right, n-not bad, p-poor. Percentages for the service levels are: g-good service=25%,a-all right=15%,n-not bad=10%,p-poor= 0% . Calculate the tip. Add validation of the input, round up the tip amount and change the background color to green for good service, pink for all right, orange for not bad, colors..

Please HElp!!

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

c++ CODE :

#include <bits/stdc++.h>
using namespace std;
int main()
{
double totalBil; // int variable totalBil use it as input.
char c; // char variable c , this is service rating.
    Label: cout<<"enter the total bill: ";
cin>>totalBil; // user input of totalBil
cout<<"select service Rating from g, a, n, p : ";
   cin>>c; // user input of service rating
if(c!='g'&&c!='a'&&c!='n'&&c!='p'){ // it checks the validation of input
cout<<"enter valid inputs\n";
goto Label;
}
switch(c){ // switch case to calculate the final bil accoring to service rating
case 'g': // if service rating g is provided by user means good service
{
system("color 20"); // it change color to green
totalBil += (totalBil*.25); // it add 25% of total bil to bil
cout<<"totalBil after Tip: "<<totalBil;
break;
}
case 'a': // if service rating is a means All right.
   {
system("color D0"); // Change background to pink
totalBil += (totalBil*.15); // it adda 15% of TotalBil to Bil
cout<<"totalBil after Tip: "<<totalBil;
break;
}
case 'n': // if service rating is n it means not bad
   {
system("color E0");
totalBil += (totalBil*.10); // it adds 10% of total bil to bil.
cout<<"totalBil after Tip: "<<totalBil;
break;
}
case 'p': // if servise rating is p it means poor service
   {
cout<<"totalBil after Tip: "<<totalBil;
break;
}
}

return 0;
}

OUTPUT:

I comment the code in order to understand.

I couldn't find orange color code so I put light Yellow.

Add a comment
Know the answer?
Add Answer to:
When you go to a restaurant you need to calculate the tip that you need to...
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
  • A traveler dines at a restaurant along an interstate highway. Both he and the waiter who...

    A traveler dines at a restaurant along an interstate highway. Both he and the waiter who serves him are rational and self-interested in the narrow sense. The waiter must first choose between providing good service or bad service, whereupon the diner must choose between leaving the customary tip or leaving no tip at all. The payoffs for their interaction are as summarized on the accompanying game tree. What is the most the diner would be willing to pay for the...

  • 1. Need help with a Java application that will compute tip amounts based on user input....

    1. Need help with a Java application that will compute tip amounts based on user input. Please let me know what else my code could use. My code is below and I need help formatting the output and calculating the amount paid by each person. Your application will: ask the user for a restaurant name, a waiter/waitress name, a bill amount and the number of people splitting the bill calculate 10%, 15% and 20% tips on the bill amount calculate...

  • 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...

  • corresponding psuedo code for the following problem: A customer visits Mandy’s Restaurant for dinner and determines...

    corresponding psuedo code for the following problem: A customer visits Mandy’s Restaurant for dinner and determines the total amount owed for the dinner following the rules listed below. • There is always 7% sales tax that will be added to the total amount spent on food and beverages. • A gratuity (tip) is always added to the total based on the quality of service received. Quality of service is a rating from 0 – 10. Assume that the value entered...

  • NEED HELP WITH ALL PLEASE. MICROBIOLOGY You have stained a bacteria using the Gram staining technique...

    NEED HELP WITH ALL PLEASE. MICROBIOLOGY You have stained a bacteria using the Gram staining technique what color would any endospores be if present? A. Colorless B. Green C. Pink D. Blue E. Purple 2. If you omitted the Safranin step in a gram staining procedure, what would be the color of a Gram-negative bacteria? A. Colorless B. Pink C. Green D. Purple E. Blue 3. Bacillus licheniformis would be what color and shape after a Gram staining? A. Purple...

  • M&M's Color Distribution: Suppose the makers of M&M candies give the following average percentages for the...

    M&M's Color Distribution: Suppose the makers of M&M candies give the following average percentages for the mix of colors in their bags of plain chocolate M&M's. Stated Distribution of Colors Brown Yellow Red Orange Green Blue Percent   30%   20%   20%   10%   10%   10% Now, you randomly select 200 M&M's and get the counts given in the table below. You expected about 20 blues but only got 11. You suspect that the maker's claim is not true. Observed Counts by Color...

  • Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my Sunshine Café...

    Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my Sunshine Café bill after I received and signed my credit card receipt,” Mr. Mark Otter said to the restaurant manager, Brad Gladiolus. “Mr. Otter, mail me a copy of the restaurant receipt and I’ll investigate,” responded Mr. Gladiolus. “I don’t have the receipt—I lost it—but I have my monthly credit card statement,” replied Mr. Otter. Mr. Gladiolus hesitated, then said, “Mr. Otter, I don’t...

  • People tend to be more generous after receiving good news. Are they less generous after receiving...

    People tend to be more generous after receiving good news. Are they less generous after receiving bad news? The average tip left by adult Americans is 21%. Give 20 patrons of a restaurant a message on their bill warning them that tomorrow's weather will be bad and record the percentage tip they leave. Given are the tips as a percentage of the total bil. 18 19.119.2 18.8 18.4 19 18.5 16.1 16.8 18.2 14 1713.6 17.5 20 20.2 18.818 23.2...

  • *NEED HELP PLEASE! ALSO Please show you got the Standard deviation to get the margin of error!** 1. To summarize the...

    *NEED HELP PLEASE! ALSO Please show you got the Standard deviation to get the margin of error!** 1. To summarize the data, compute the proportion of all clients that a. Answered "Poor"to room quality b. Answered "Poor"to food quality C. Answered "Poor" to service quality 2. Develop the 92% confidence interval for the proportion of all recent clients that were "dissatisfied." What is the margin of error? What are the lower (or left) and upper (or right) endpoints of the...

  • Need 5-9 and number 11 all answered. Thx 5. How can two individuals with brown eyes(B)...

    Need 5-9 and number 11 all answered. Thx 5. How can two individuals with brown eyes(B) have a blue (b) eyed baby? Show the genotypes of the parents and Punnett square to prove your answer. What are the chances of a blue-eyed baby? 6. A homozygous tongue roller (T) is married to a non-tongue roller(t). If they have 5 children, how many of them will be tongue rollers? Use Punnett square to support and explain your answer. 7. Let's imagine...

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