Question: This is in Java. Write a program for a Dinner to display the Check for the cashier. The Dinner serves a chefs menu with two

This is in Java.

Write a program for a Dinner to display the Check for the cashier. The Dinner serves a chefs menu with two options

Category Price Adjustment

Adults $31.50, The total adult Check is reduced by $5.00 if there are 9 or more adults.

Children $15.00, It is free after the third child (you pay maximum of 3 children)

The program requests the name and zip code of the Dinner and converts the text. The program then accepts the number of adults and children, performs the necessary calculations, computes the 6% tax, and displays the Check. Follow the formatting of the example below.

Enter name of Dinner: moNet

Enter zip code: 51537

Enter number of adults (-1 to stop).. 9

Enter number of children............. 4

Monet Dinner

Hawksburg

~~~~~~~~

All you can eat Dinner at a great price!!!

Price Total

Adults 9 $31.50 $278.50

Children 4 $15.00 $45.00

Subtotal $323.50

Tax (6%) $19.41

Total Check $342.91

Enter number of adults (-1 to stop)..

DinnerDemo should follow this sequence: Request the name and zip code of the Dinner from the user. Use the Dinner class to set the Dinner name and the location but do not display it. You will display the Dinner information in the while loop with the other output.

The while loop: Requests the number of meals for adults and children. Uses the Check class to instantiate these objects: adultCheck childCheck Uses the Check class to calculate the adult and child costs. Uses the Check class to calculate the tax. The call should look like this: ??? = Check.calcTax(???); Totals the costs. Displays the Dinner name and location created earlier using the Dinner class use the toString method (the title of the Check) Displays the two lines showing the adult and child costs using the Check class use the display method. Displays the subtotal of the Check. Displays the tax. Use Check.TAXRATE to get the current tax rate (6%) from the Check class and format the value as percentage. Displays the total of the Check. Requires two classes: Dinner and Check

The Dinner Class Dinner has these instance variables String name String location The constructor (assigns the returned value from the setters to the properties): Call the setName method to assign a value to name, using the value passed to it (the name of the Dinner as entered by the user.) Call the setLocation method to assign a value to location, using the value passed to it (the zip code as entered by the user.) Zip code must be an integer. Dinner contains these methods.

setName method changes the name entered by the user so that the first character is uppercase, the rest of the characters are lower case, and Dinner is attached. This method returns a string. setLocation method uses the zip code entered by the user to determine the location. Concatenate the underline using the ~ character; the underline must be the same size as the location. In addition, add the following line: All you can eat Dinner at a great price!!!. This method returns the concatenated string. Use a nested if or switch Zip Code Location

51504 for Burtson; 51537 for Hawksburg; Any other value is Filmore;

toString method returns a string that displays the first four lines of the receipt.

The Check Class Set up a final for the tax rate like this: static final double TAXRATE = .06; Check has these instance variables: String category int mealQty double mealCost double mealPrice The constructor: category will be set to null. mealQty will be passed the number of meals ordered for the category. mealCost will be initialized to 0. mealPrice will be initialized to 0. Check contains these methods.

calcAdultCost sets the category to Adults, calculates the cost of the adult meals, sets the mealPrice, and sets and returns the mealCost. calcChildCost sets the category to Children, calculates the cost of the childrens meals, sets the mealPrice, and sets and returns the mealCost. calcTax calculates the tax. Return the calculated tax based on the total sent to this method. Set up the method like this: static double calcTax(double total) display displays the category, mealQty, mealPrice, and mealCost. Format the number accordingly using the currency format. The method header looks like this: public void display(). Total of 3 java files.

Thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!