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

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

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

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

  • updated Question 5 of 9 > People tend to be more generous after receiving good news....

    updated Question 5 of 9 > 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 bill. 18 19.1 19.2 18.8 18.4 19 18.5 16.1 16.8 18.2...

  • need help with #20 and #48 please add proper charges, balanced equation, and proper subscript (aq,solid,liquid,...

    need help with #20 and #48 please add proper charges, balanced equation, and proper subscript (aq,solid,liquid, or gas) 20. Give the formula for a chemical substance that will yield a precipitate with CoCl2 solution, but not with ZnCl, solution (if excess of substance is required, so state). Include net ionic equations for any reactions that occur. ANALYSIS OF THE ALUMINUM-NICKEL GROUP (GROUP III) Solutions containing Fo?", Fe, Co, Nid", Mn?, Art, Cr". Zn?N, Ba?". Ca, Mg, Na, K [NHACI, excess...

  • PLEASE HELP ME! ASAP PLEASE!! If you need anymore information, please ask. This is what we...

    PLEASE HELP ME! ASAP PLEASE!! If you need anymore information, please ask. This is what we were given and I am having trouble! 1) Saturated Sodium Chloride Solution Equilibrium System: Observations upon addition ofHCI: white precipitate In which direction did this stress cause the equilibrium system to shif? Left or Right Which ion caused the shift? Explain. 2) Acidified Chromate Solution Equilibrium System: Observations upon addition ofHNO:: solution becomes orange Left or Right In which direction did this stress cause...

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
ADVERTISEMENT