Question

In: Computer Science

Using Java Calculating the tip when you go to a restaurant is not difficult, but your...

Using Java

Calculating the tip when you go to a restaurant is not difficult, but your restaurant wants to suggest a tip according to the service diners receive. Write a program that calculates a tip according to the diner’s satisfaction as follows:

•Ask for bill amount

•Ask for the diners’ satisfaction level using these ratings: 1 = Totally satisfied, 2 = Satisfied, 3 = Dissatisfied.

•If the diner is totally satisfied, calculate a 20 percent tip.

•If the diner is satisfied, calculate a 15 percent tip.

•If the diner is dissatisfied, calculate a 10 percent tip.

•Report the satisfaction level and tip in dollars and cents

Format tips to 2 decimal points; if the bill is 105$ and satisfaction level is 3, then the tip will be $10.50

Solutions

Expert Solution

//Java Program

import java.util.Scanner;

public class Tip {
   public static void main(String args[]) {
       double bill;
       int rating;
       double tip=0;
      
       Scanner in = new Scanner(System.in);
       System.out.print("Enter bill amount : ");
       bill = in.nextDouble();
      
       System.out.print("Enter Rating : ");
       rating = in.nextInt();
      
       if(rating==1)tip = bill*0.2;
       else if(rating==2)tip = bill*0.15;
       else if(rating==3)tip = bill*0.1;
      
       System.out.printf("Tip amount : $%.2f",tip);
       in.close();
   }
}
//screenshot


Related Solutions

When calculating confidence intervals with two samples, the difficult part is deciding whether the differences you...
When calculating confidence intervals with two samples, the difficult part is deciding whether the differences you observe in two groups are statistically significant. The confidence intervals can help you make that decision. When comparing the means of two groups, subtract one mean from the other. If they are the same, the answer will be zero. Remember that with the 95% confidence interval there is a range of values that contain the true mean in 95 of 100 samples. If zero...
According to game theory, why are you more likely to tip well at a restaurant you...
According to game theory, why are you more likely to tip well at a restaurant you frequent than at a restaurant you seldom patronize (assuming the service and food are equally comparable)?
Write in java Let's assume I go a restaurant, List of meals such as breakfast and...
Write in java Let's assume I go a restaurant, List of meals such as breakfast and lunch and dinner is displayed to me I can pick breakfast, lunch, and dinner after I pick any of the breakfast lunch and dinner, a list of food/prices offered for breakfast is shown so I will see the breakfast menu such an egg, milk and their prices, after that I pick milk. then I am asked to two more sides from the menu which...
In this exercise, you will complete the Restaurant Tip application from Chapter 2’s Focus on the...
In this exercise, you will complete the Restaurant Tip application from Chapter 2’s Focus on the Concepts lesson. The application’s Planning Chart is shown in Figure 3-34. Use either a flowchart or pseudocode to plan the btnCalc_Click procedure, which should calculate and display a server’s tip. Open the Tip Solution.sln file contained in the VB2017\Chap03\Tip Solution folder. Enter the three Option statements in the Code Editor window. Use the comments as a guide when coding the btnCalc_Click procedure. Be sure...
1) Assume an air bubble had been in the buret tip when you took your first...
1) Assume an air bubble had been in the buret tip when you took your first reading and it was replaced by NaOH during the course of the titration. Would your experimental value for the concentration of NaOH be too high, too low, or unchanged as compared to the true value? Explain 2) Assume the buret had been wet with water because it was not adequately rinsed with base. Would your experimental value for concentration of NaOH be too high,...
Restaurant Selector IN JAVA You have a group of friends coming to visit for your high...
Restaurant Selector IN JAVA You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaurant. You aren’t sure if any of them have dietary restrictions, but your restaurant choices are as follows: Joe’s Gourmet Burgers – Vegetarian: No, Vegan: No, Gluten-Free: No Main Street Pizza Company – Vegetarian: Yes, Vegan: No, Gluten-Free: Yes Corner Café – Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Mama’s Fine...
You are dining at your favorite restaurant and eating your favorite meal when you start to...
You are dining at your favorite restaurant and eating your favorite meal when you start to think about the digestion process (sorry to ruin your meal). Briefly explain this process when food enters your stomach then in your small intestine. Include the following terms/structures in your explanation: stomach; chyme; hydrochloric acid; 3 basic tasks of stomach; length of time in stomach; 3 structural parts of small intestine; describe what happens in the first 25 centimeters of the small intestine; role...
Scenario 1: You are working as a waitress in a restaurant. You go to check on...
Scenario 1: You are working as a waitress in a restaurant. You go to check on your table to see how their food is. As you are walking up to the table, one of the customers begins coughing. They suddenly stop coughing and start clutching their throat. Their lips begin to turn a bluish color and the family around the table begins to panic. You are first aid certified and want to help the victim. (1) What are the initial...
ASAP PLEASE!!!! USING JAVA /* 1. When should you use a do-while loop? ** Write your...
ASAP PLEASE!!!! USING JAVA /* 1. When should you use a do-while loop? ** Write your answer as a multi-line Java comment ** */ /* 2. Identify the algorithm that matches this code snippet. Your choices are:   sum and average, counting matches, first match, prompt until match, and   comparing adjacent values.  Write your answer below the coded.        int firstNum = 0;   int number = scnr.nextInt();   while (scnr.hasNextInt())   {   int input = scnr.nextInt();   if (input == number)   {   firstNum++;   }   }...
Reflect on the times when you encountered a difficult or "red flag" sutuation What was your...
Reflect on the times when you encountered a difficult or "red flag" sutuation What was your reaction and why? ( feelings)What did you do? ( behavior) What could you have done differently? Would Legislation ( e.g., mandatory staffing ratios)"have helped ? what steps were taken if any to prevent the same scenario from reoccurring in future
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT