Project 3 The Cafe Problem complete solutions correct answers key
- Vpqnrqhwk
- Rating : 40
- Grade : A+
- Questions : 2
- Solutions : 1079
- Blog : 0
- Earned : $19352.58
Project 3 The Cafe Problem complete solutions correct answers key
Project 3 The Cafe Problem
Write a program for a cafe to display the bill for the cashier. The cafe serves a chef’s menu with two options Category
Price
Adjustment
Adults
$31.50
The total adult bill is reduced by $4.00 if there are 8 or more adults.
Children
$15.00
The program requests the identification number for the cafe and the starting order number. The program then accepts the number of adults and children, performs the necessary calculations, computes the 6% tax, and displays the bill similar to the example below.
Enter cafe identifier: 252
Enter first order number: 100
Enter number of adults (-1 to stop).....8
Enter number of children................2
White Marsh Cafe
Order Number = 100
Price Total
Adults 8 31.50 248.00
Children 2 15.00 30.00
Tax (6%) 16.68
Total bill 294.68
Enter number of adults (-1 to stop).....
main should follow this sequence:
Request the identification number for the cafe and the starting order number from the user.
Use the Cafe class to set up the cafe name but do not display it.
You will display the cafe name and order number in the while loop with the other output.
The while loop (adults is the sentinel value so get the value once before the loop and once at the end of the loop):
Requests the number of meals for adults and children.
Uses the Bill class to instantiate these objects:
adultBill
childBill
Uses the Bill class to calculate the adult and child costs.
Uses the Bill class to calculate the tax. The call should look like this:
??? = Bill.calcTax(???);
Totals the costs.
Displays the cafe name and order number created earlier using the Cafe class
– use the toString method.
Displays the two lines showing the adult and child costs using the Bill class
– use the display method.
Displays the tax. Use Bill.TAXRATE to get the current tax rate (6%) from the Bill class.
Displays the total cost.
You will be coding two classes: Cafe and Bill.
The Cafe Class – write and test one method at a time.
Cafe has these instance variables in the constructor:
String cafeID is assigned the value passed to it (the cafe identification number entered by the user in main).
Integer orderNum is assigned the value passed to it (the starting order number entered by the user in main).
String cafeName is assigned null.
Cafe contains these methods.
setName method uses cafeID to determine the café name. This method returns a string. Use a nested if or switch.
Cafe ID
Cafe Name
101
Essex Cafe
252
White Marsh Cafe
Any other value
Towson Cafe
The Bill Class
Set up a final for the tax rate like this:
static final double TAXRATE = .06;
Bill has these instance variables in the constructor:
String category will be set to null.
int mealQty will be passed the number of meals ordered for the category.
double mealCost will be initialized to 0.
double mealPrice will be initialized to 0.
Bill 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 children’s 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. Use one printf similar to this:
System.out.printf( "\n %-10s %3d %6.2f %7.2f",
category, mealQty, mealPrice, mealCost);
You can copy/paste the above code into the display method.
The method header looks like this:
public void display()
You will be submitting 3 java files for the final version. Any class, variable or method names in bold must be used in your program.
Project Points – Check Schedule for due dates.
What to include
Project 3 – Part I (30 points)
Submit a UML diagram for the Cafe class.
Submit the Cafe class code.
Do not submit your main code. A class should work with any main so I will test it with my main. You should, however, code main so you can test the Cafe class as well as the rest of the requirements.
Project 3 - Final Version
(100 points)
Final Version of main, Cafe and Bill classes
Here is the pseudocode for main to test your Cafe class required for Part I:
get cafe id
get order number
instantiate the object (tests the Cafe constructor)
call setName (tests the setName method)
print object name (tests the toString method)
When this code works then add the while loop to main to test that the order number increases.
get cafe id
get order number
instantiate the object (tests the Cafe constructor)
call setName (tests the setName method)
get adults
while(adults != -1)
{
print object name (tests the toString method)
get adults
}
[Solved] Project 3 The Cafe Problem complete solutions correct answers key
- This solution is not purchased yet.
- Submitted On 12 Jan, 2017 03:06:23
- Vpqnrqhwk
- Rating : 40
- Grade : A+
- Questions : 2
- Solutions : 1079
- Blog : 0
- Earned : $19352.58