Java hamburger class and driver program: 1 - you will be creating a Uml for the
ID: 3684548 • Letter: J
Question
Java hamburger class and driver program:
1 - you will be creating a Uml for the hambrger class.
2 - java code for the hamburger class.
3- "driver" program.
Hambruger class contains the following attributes/ properties:
- meatType: can be : (beef, turkey, veggie) with beef as the default
- numberOfPatties: choice of 1, 2, or 3.
- the cost of the buger ($11.29 for 1 patty) , cost for extra patty $2.95
- type of bread: Kaiser/regular, sesame-seed, whole-wheat, white, or potato-roll
(howCooked; choice of : well, medium, medium-rare, or rare
the class did not care how it was cooked, so this attribute is removed)
- stantdardToppingList: a list of the Standard toppping at no extra cost that would be: tomato, lettuce, pickle, onion.
- counterT : for th number of standard toppings.
- standardSauceList: a list of the standard sauces at no extra cost would be: ketchup, yellow mustard, honey mustard, spicy brown mustard,
mayonnaise, chipotle mayonnaise, or BBQ
- counterS: for the number of standard sauces
- cheeseToppingList: choices of Cheese: American, Chedder, Pepper jack, Monterey jack, Swiss or Mozzarella
- numberOfCheeseToppings: another counter
- costOfCheeseTopping: cost is $1.00 for each.
- delauxToppingList: a list of topping at an extra cost for (red onions, bacon, banana peppers, and jalapenos)
- counterD: for the number of delaux toppings.
- costOfDeluxe Topping: Cost is $1.25 for each.
Methods: sets and gets for each of the attributes/properties. Include a no-argument constructor that defaults to: 1 beef patty on a sesame-seed bun, no toppings of any kind.
In your driver program: ask the user for their choices, if the input is invalid, then the program will use the default value.
Specifically: 1 beef patty on a sesame-seed bun, no toppings.
your program: will display the entire order. your program should calculate: sub-total amount, amount of tax (8.625%),
and grand total. The money output should have both a $ and 2 decimal places.
REMEMBER: to include internal documentation.
-------------------------------------------------------------------------------------------------------------------------------------------------
I HAD THE FOLLOWING DONE BUT NEED HELP WITH THE DRIVER PROGRAM :
package com.dq.thematrix.main.java.utilities;
public class Hamburger {
double numberOfPatties;
String meatType;
double cost;
String breadType;
String stantdardToppingList[];
int counterT;
String standardSauceList[];
int counterS;
String cheeseToppingList[];
int numberOfCheeseToppings;
int costOfCheeseTopping;
String delauxToppingList[];
int counterD;
int costOfDeluxe;
public double getNumberOfPatties() {
return numberOfPatties;
}
public void setNumberOfPatties(double numberOfPatties) {
this.numberOfPatties = numberOfPatties;
}
public String getMeatType() {
return meatType;
}
public void setMeatType(String meatType) {
this.meatType = meatType;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public String getBreadType() {
return breadType;
}
public void setBreadType(String breadType) {
this.breadType = breadType;
}
public String[] getStantdardToppingList() {
return stantdardToppingList;
}
public void setStantdardToppingList(String[] stantdardToppingList) {
this.stantdardToppingList = stantdardToppingList;
}
public int getCounterT() {
return counterT;
}
public void setCounterT(int counterT) {
this.counterT = counterT;
}
public String[] getStandardSauceList() {
return standardSauceList;
}
public void setStandardSauceList(String[] standardSauceList) {
this.standardSauceList = standardSauceList;
}
public int getCounterS() {
return counterS;
}
public void setCounterS(int counterS) {
this.counterS = counterS;
}
public String[] getCheeseToppingList() {
return cheeseToppingList;
}
public void setCheeseToppingList(String[] cheeseToppingList) {
this.cheeseToppingList = cheeseToppingList;
}
public int getNumberOfCheeseToppings() {
return numberOfCheeseToppings;
}
public void setNumberOfCheeseToppings(int numberOfCheeseToppings) {
this.numberOfCheeseToppings = numberOfCheeseToppings;
}
public int getCostOfCheeseTopping() {
return costOfCheeseTopping;
}
public void setCostOfCheeseTopping(int costOfCheeseTopping) {
this.costOfCheeseTopping = costOfCheeseTopping;
}
public String[] getDelauxToppingList() {
return delauxToppingList;
}
public void setDelauxToppingList(String[] delauxToppingList) {
this.delauxToppingList = delauxToppingList;
}
public int getCounterD() {
return counterD;
}
public void setCounterD(int counterD) {
this.counterD = counterD;
}
public int getCostOfDeluxe() {
return costOfDeluxe;
}
public void setCostOfDeluxe(int costOfDeluxe) {
this.costOfDeluxe = costOfDeluxe;
}
public Hamburger() {
numberOfPatties=1;
meatType="beef";
breadType="sesame-seed";
}
Explanation / Answer
Hamburger.java
package org.students;
import java.util.Arrays;
public class Hamburger {
int numberOfPatties;
String meatType;
double cost;
String breadType;
String stantdardToppingList[];
int counterT;
String standardSauceList[];
int counterS;
String cheeseToppingList[];
int numberOfCheeseToppings;
double costOfCheeseTopping;
String delauxToppingList[];
int counterD;
double costOfDeluxe;
public double getNumberOfPatties() {
return numberOfPatties;
}
public void setNumberOfPatties(int numberOfPatties) {
this.numberOfPatties = numberOfPatties;
}
public String getMeatType() {
return meatType;
}
public void setMeatType(String meatType) {
this.meatType = meatType;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public String getBreadType() {
return breadType;
}
public void setBreadType(String breadType) {
this.breadType = breadType;
}
public String[] getStantdardToppingList() {
return stantdardToppingList;
}
public void setStantdardToppingList(String[] stantdardToppingList) {
this.stantdardToppingList = stantdardToppingList;
}
public int getCounterT() {
return counterT;
}
public void setCounterT(int counterT) {
this.counterT = counterT;
}
public String[] getStandardSauceList() {
return standardSauceList;
}
public void setStandardSauceList(String[] standardSauceList) {
this.standardSauceList = standardSauceList;
}
public int getCounterS() {
return counterS;
}
public void setCounterS(int counterS) {
this.counterS = counterS;
}
public String[] getCheeseToppingList() {
return cheeseToppingList;
}
public void setCheeseToppingList(String[] cheeseToppingList) {
this.cheeseToppingList = cheeseToppingList;
}
public int getNumberOfCheeseToppings() {
return numberOfCheeseToppings;
}
public void setNumberOfCheeseToppings(int numberOfCheeseToppings) {
this.numberOfCheeseToppings = numberOfCheeseToppings;
}
public double getCostOfCheeseTopping() {
return costOfCheeseTopping;
}
public void setCostOfCheeseTopping(int costOfCheeseTopping) {
this.costOfCheeseTopping = costOfCheeseTopping;
}
public String[] getDelauxToppingList() {
return delauxToppingList;
}
public void setDelauxToppingList(String[] delauxToppingList) {
this.delauxToppingList = delauxToppingList;
}
public int getCounterD() {
return counterD;
}
public void setCounterD(int counterD) {
this.counterD = counterD;
}
public double getCostOfDeluxe() {
return costOfDeluxe;
}
public void setCostOfDeluxe(int costOfDeluxe) {
this.costOfDeluxe = costOfDeluxe;
}
public Hamburger() {
numberOfPatties=1;
meatType="beef";
breadType="sesame-seed";
}
public Hamburger(int numberOfPatties, String meatType, double cost,
String breadType, String[] stantdardToppingList, int counterT,
String[] standardSauceList, int counterS,
String[] cheeseToppingList, int numberOfCheeseToppings,
double costOfCheeseTopping, String[] delauxToppingList, int counterD,
Double costOfDeluxe) {
super();
this.meatType = meatType;
this.numberOfPatties = numberOfPatties;
if(numberOfPatties==1)
this.cost=11.29;
else if(numberOfPatties==2)
this.cost=11.29+2.95;
else if(numberOfPatties==3)
this.cost=11.29+2*2.95;
this.breadType = breadType;
this.stantdardToppingList = stantdardToppingList;
this.counterT = counterT;
this.standardSauceList = standardSauceList;
this.counterS = counterS;
this.cheeseToppingList = cheeseToppingList;
this.numberOfCheeseToppings = numberOfCheeseToppings;
this.costOfCheeseTopping = numberOfCheeseToppings * 1.00;
this.delauxToppingList = delauxToppingList;
this.counterD = counterD;
this.costOfDeluxe = counterD * 1.25;
}
//This method is used to display the contents of the Hamburger Object.
@Override
public String toString() {
return "Hamburger [numberOfPatties=" + numberOfPatties + ", meatType="
+ meatType + ", cost=" + cost + ", breadType=" + breadType
+ ", stantdardToppingList="
+ Arrays.toString(stantdardToppingList) + ", counterT="
+ counterT + ", standardSauceList="
+ Arrays.toString(standardSauceList) + ", counterS=" + counterS
+ ", cheeseToppingList=" + Arrays.toString(cheeseToppingList)
+ ", numberOfCheeseToppings=" + numberOfCheeseToppings
+ ", costOfCheeseTopping=" + costOfCheeseTopping
+ ", delauxToppingList=" + Arrays.toString(delauxToppingList)
+ ", counterD=" + counterD + ", costOfDeluxe=" + costOfDeluxe
+ "]";
}
}
______________________________________________________________________________________________
HamburgerTest.java
package org.students;
import java.text.DecimalFormat;
import java.util.Scanner;
public class HamburgerTest {
public static void main(String[] args)
{
// This object will be used to format the double to two decimal places.
DecimalFormat df=new DecimalFormat("#.##");
String stantdardToppingList[];
String standardSauceList[];
String cheeseToppingList[];
String delauxToppingList[];
// To read from Keyboard
Scanner sc=new Scanner(System.in);
Scanner sc1=new Scanner(System.in);
Scanner sc2=new Scanner(System.in);
Scanner sc3=new Scanner(System.in);
Scanner sc4=new Scanner(System.in);
Scanner sc5=new Scanner(System.in);
System.out.println("=========================Hamburger===================");
System.out.println(" ");
System.out.print("Select The type of meet from (beef, turkey, veggie)::");
String meatType=sc.next();
System.out.print("No Of Patties(1 (or) 2 (or) 3)::");
int numberOfPatties=sc1.nextInt();
System.out.print(" The cost of the buger ($11.29 for 1 patty) , cost for extra patty $2.95::");
double cost=sc.nextDouble();
System.out.println("*Type of bread: Kaiser/regular, sesame-seed, whole-wheat, white, or potato-roll *");
System.out.print("Enter Type of bread:");
String breadType=sc.next();
System.out.println("* Standard Toppings-tomato, lettuce, pickle, onion. *");
System.out.print("No of standard toppings ::");
int counterT=sc.nextInt();
stantdardToppingList=new String[counterT];
for(int i=0;i<counterT;i++)
{
System.out.print("Enter Name of Standard Topping "+(i+1)+"::");
stantdardToppingList[i]=sc2.nextLine();
}
System.out.println(" *standardSauceList: ketchup, yellow mustard, honey mustard, spicy brown mustard, mayonnaise, chipotle mayonnaise, or BBQ* ");
System.out.print("No of number of standard sauces ::");
int counterS=sc.nextInt();
standardSauceList=new String[counterS];
for(int i=0;i<counterS;i++)
{
System.out.print("Enter Name of standard sauces "+(i+1)+"::");
standardSauceList[i]=sc3.nextLine();
}
System.out.println("* cheeseToppingList: American, Chedder, Pepper jack, Monterey jack, Swiss or Mozzarella *");
System.out.print("NumberOfCheeseToppings:");
int numberOfCheeseToppings=sc.nextInt();
cheeseToppingList=new String[numberOfCheeseToppings];
for(int i=0;i<numberOfCheeseToppings;i++)
{
System.out.print("Enter Name of Cheese Toppings "+(i+1)+"::");
cheeseToppingList[i]=sc4.nextLine();
}
System.out.print("Enter cost Of Cheese Topping(1.00 $)per Toping:");
double costOfCheeseTopping=sc1.nextDouble();
System.out.println("* delauxToppingList:(red onions, bacon, banana peppers, and jalapenos) *");
System.out.print("The number of delaux toppings::");
int counterD=sc.nextInt();
delauxToppingList=new String[counterD];
for(int i=0;i<counterD;i++)
{
System.out.print("Enter Name of delaux Toppings "+(i+1)+"::");
delauxToppingList[i]=sc5.nextLine();
}
System.out.println("* costOfDeluxe Topping: Cost is $1.25 for each *");
System.out.print("Enter Cost of Delux Topping:");
double costOfDeluxe=sc.nextDouble();
Hamburger h=new Hamburger(numberOfPatties, meatType, costOfDeluxe, breadType, stantdardToppingList, counterT, standardSauceList, counterS, cheeseToppingList, numberOfCheeseToppings, costOfCheeseTopping, delauxToppingList, counterD, costOfDeluxe);
double itemTotal=h.getCost()+h.getCostOfCheeseTopping()+h.getCostOfDeluxe();
double subtotal=itemTotal*(8.625/100);
double grandTotal=itemTotal+subtotal;
System.out.println(" ");
System.out.println(h.toString());
System.out.println(" ");
System.out.println("Cost of Hamburger is:"+df.format(itemTotal)+" $");
System.out.println("Tax @ 8.625 is:"+df.format(subtotal)+" $");
System.out.println("Grand Total:"+df.format(grandTotal)+" $");
}
}
______________________________________________________________________________________________
output:
=========================Hamburger===================
Select The type of meet from (beef, turkey, veggie)::beaf
No Of Patties(1 (or) 2 (or) 3)::2
The cost of the buger ($11.29 for 1 patty) , cost for extra patty $2.95::11.29
*Type of bread: Kaiser/regular, sesame-seed, whole-wheat, white, or potato-roll *
Enter Type of bread:seseme-seed
* Standard Toppings-tomato, lettuce, pickle, onion. *
No of standard toppings ::2
Enter Name of Standard Topping 1::lettuce
Enter Name of Standard Topping 2::onion
*standardSauceList: ketchup, yellow mustard, honey mustard, spicy brown mustard, mayonnaise, chipotle mayonnaise, or BBQ*
No of number of standard sauces ::2
Enter Name of standard sauces 1::yellow mustard
Enter Name of standard sauces 2::bbq
* cheeseToppingList: American, Chedder, Pepper jack, Monterey jack, Swiss or Mozzarella *
NumberOfCheeseToppings:2
Enter Name of Cheese Toppings 1::cheddar
Enter Name of Cheese Toppings 2::pepper jack
Enter cost Of Cheese Topping(1.00 $)per Toping:1.00
* delauxToppingList:(red onions, bacon, banana peppers, and jalapenos) *
The number of delaux toppings::1
Enter Name of delaux Toppings 1::bacon
* costOfDeluxe Topping: Cost is $1.25 for each *
Enter Cost of Delux Topping:1.25
Hamburger [numberOfPatties=2, meatType=beaf, cost=14.239999999999998, breadType=seseme-seed, stantdardToppingList=[lettuce, onion], counterT=2, standardSauceList=[yellow mustard, bbq], counterS=2, cheeseToppingList=[cheddar, pepper jack], numberOfCheeseToppings=2, costOfCheeseTopping=2.0, delauxToppingList=[bacon], counterD=1, costOfDeluxe=1.25]
Cost of Hamburger is:17.49 $
Tax @ 8.625 is:1.51 $
Grand Total:19 $
_____________________________________________________________________________________________
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.