This assignment requires a program that asks a customer for their burger order and outputs the order and price. I can't figure out how to fix the errors that I'm getting here. Please help. I'm new to Java and not very good at it.
import java.util.Scanner; public class Hamburger { Scanner sc=new Scanner(System.in); //write constructor for single on white w/ no cheese and no toppings for $1.99 String bun=" "; int patties=1; boolean addCheese=false; String toppings=" "; double price=1.99; public boolean getAddCheese() { return addCheese; } public void setAddCheese(int newAddCheese) { System.out.println("Welcome to Dead Cow on a Bun. Would you like cheese on your dead cow?"); String cheese = sc.next(); boolean addCheese = true; if(cheese.equalsIgnoreCase("Yes")) { addCheese = true; } else if(cheese.equalsIgnoreCase("No")) { addCheese = false; } } public int getSuperSizeIt() { return patties; } public void setSuperSizeIt(int newPatties) { patties=newPatties; System.out.println("Do you want to supersize your dead cow?"); String superSizeIt=sc.next(); if(superSizeIt.equalsIgnoreCase("Yes") || superSizeIt.equalsIgnoreCase("y")) { price=price+1.0; patties=patties+1; } } public String getBun() { return bun; } public void setBun(String newBun) { System.out.println("What kind of bun would you like?"); bun=newBun; } public int getToppings() { return toppingChoices; } public void setToppings(String newtoppingChoices) { String[] toppings = {"Bacon", "Grilled Mushrooms", "Lettuce", "Onion Jam", "Magic Sauce"}; String[] toppingChoices = new String[5]; for(int index=0; index< toppings.length; index++) { System.out.println("Please answer Y or N. Would you like " +toppings[index]); toppingChoices[index]=sc.nextLine(); } } //burgerDetails - prints order public void burgerDetails(boolean addCheese, int patties, String bun, String toppingChoices) { System.out.println("Cheese: " +addCheese); System.out.println("Patties: " +patties); System.out.println("Bun: " +bun); System.out.print("Toppings: " +toppingChoices[index]); } }
Here are the errors I'm getting:
Hamburger.java:73: error: cannot find symbol return toppingChoices; ^ symbol: variable toppingChoices location: class Hamburger Hamburger.java:94: error: cannot find symbol System.out.print("Toppings: " +toppingChoices[index]); ^ symbol: variable index location: class Hamburger Hamburger.java:94: error: array required, but String found System.out.print("Toppings: " +toppingChoices[index]);