Pizza Anyone?

Run Settings
LanguageJava
Language Version
Run Command
/* *This program allows a user to select a *pizza size as well as the number of pizzas *they want. *The program calculates the costs depending on *what the user selects, giving them the total cost afterwards. *Author: Ryan Loo *Teacher: Mr. Rilett *Date created: 22/3/2021 */ import java.util.Scanner;//Importing scanner from java import java.text.DecimalFormat;//Importing text for decimal formatting class Pizza { public static void main(String[] args) { //Calling on the decimal format so that the numbers are properly formatted DecimalFormat df = new DecimalFormat("$###.##"); //Variables int pizzaSize=0, pizzaCount=0; double labourCost = 1.00; double storeCost = 1.50; double materials = 0.50; double totalCost, labourCost2, storeCost2, materials2; //Scanner name Scanner putt = new Scanner(System.in); String inputSize = putt.nextLine();//looks for the first line in input //Introduction System.out.println("Welcome to Lemons's Pizzeria!"); System.out.println("Please have a look at what we have to offer for your pizza experience."); System.out.println("You can look at our menu below!"); //In-store menu System.out.println("---------------------------------"); System.out.println("|\t In-Store Menu |"); System.out.println("| Small(6) |"); System.out.println("| Medium(8) |"); System.out.println("| Large(10) |"); System.out.println("| XLarge(12) |"); System.out.println("---------------------------------"); System.out.println("You Selected a Size: "); //If statements for declaring size if(inputSize.equals("small")) { System.out.println("small"); pizzaSize = 6; } else if(inputSize.equals("medium")) { System.out.println("medium"); pizzaSize = 8; } else if(inputSize.equals("large")) { System.out.println("large"); pizzaSize = 10; } else if(inputSize.equals("xlarge")) { System.out.println("xlarge"); pizzaSize = 12; } else { System.out.println("No Size Was Chosen. Please Pick a Size."); System.exit(0);//Ends the first section of code } String numberOfPizza = putt.nextLine();//Looks for second line in input, forgetting the first one pizzaCount = Integer.parseInt(numberOfPizza);//Changing the string into an int for calculations System.out.println("You Selected " +numberOfPizza+" Pizza(s)"); System.out.println("---------------------------------"); //Calculating costs System.out.println("Your bill comes down to:"); //Labour Costs labourCost2 = labourCost * pizzaCount; System.out.println("Labour cost: "+ df.format(labourCost2)); //Store Costs storeCost2 = storeCost * pizzaCount; System.out.println("Store costs: "+ df.format(storeCost2)); //Materials Costs materials2 = materials * pizzaSize; System.out.println("Material costs: "+df.format(materials2)); //Total cost totalCost = labourCost2+storeCost2+materials2; System.out.println("Your Total Cost is: "+df.format(totalCost)); //Ending System.out.println("---------------------------------"); System.out.println("We are pleased that you came to our Pizzaria!"); System.out.println("We would like you to leave a review!"); System.out.println("Please come back again!"); } }
/* * input the size chosen * input the number of pizzas * calculate the labour costs * calcualte the store costs * calculate the material costs * calculate the total costs */
Editor Settings
Theme
Key bindings
Full width
Lines