Question: Below is my original code in java. import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Pizzeria { public static void main(String[] args) { Scanner scnr
Below is my original code in java.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Pizzeria {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// variables
String userName;
String pizzaName;
double diameter;
double area = 0;
char totalDisplay = 0;
char pepperoniChoice;
double total = 0;
int numPizzas;
final double cheesePerInch = 0.0272;
final double saucePerInch = 0.0316;
final double doughPerInch = 0.0228;
final double toppingPerInch = 0.0284;
//array list of pizza
ArrayList
//array list of toppings
String[] validToppings = {"Pepperoni", "Mushroom", "Chicken", "Ham", "Pineapple", "Sausage", "Basil", "Olive"};
//user intro
System.out.println("Welcome to Adkins Pizzeria!");
System.out.println("Can I have your name please?");
userName = scnr.nextLine();
System.out.println("Ok, let's start your order, " + userName + ".");
//Menu
System.out.println("Here is what you can do next:");
System.out.println("MENU");
System.out.println("a - Add a pizza");
System.out.println("t - Print the total");
System.out.println("r - Read the order");
System.out.println("q - Quit");
System.out.println("Please make a selection:");
String selection = "";
//read users selection and store it into variable for switch statement
selection = scnr.nextLine();
switch (selection){
case "a":
System.out.println("make a pizza");
//code
break;
case "t":
System.out.println("print total");
//code
break;
case "r":
System.out.println("read the order");
//code
break;
case "q":
System.out.println("quit");
System.exit(0);
break;
default:
System.out.println("invalid please try again");
selection = scnr.nextLine();
break;
}
}
}
can someone help me build on it(still in java) within the prompts (bold) for my assignment posted below?(i will also provide a sample interaction that we were given).
Step 3: Make some upgrades to the Pizzeria.java file!
Pizzeria Class: Creates Pizza objects
Import Javas ArrayList utility
Create a String ArrayList to store our pizzas, and a String Array to store our valid topping names. Here are the toppings we have decided to carry at Adkins Pizzeria: Pepperoni, Mushroom, Chicken, Ham, Pineapple, Sausage, Basil, Olive. As we havent done market research yet, each of these toppings will cost the same per square inch (0.0284). There are no limits to the amount of pizzas that the customer can order.
Implement a selection menu of what a user can possibly do after being introduced to the Pizzeria. After each action the user takes and completes, prompt them again with the menu. Below is the list of options your program must have implemented:
a - Add a pizza
Creates a pizza
t - Print the total
Prints out the current total cost of the users order
r - Read the order
Prints out the ordered pizza names
Prints out the total number of ordered pizzas and the total cost of the pizza order.
q - Quit
Exits the program immediately
Here is the process of adding a pizza (Option a):
Provide the number of the current pizza and ask for its name.
Ask for the size of the pizza.
Ask for (and validate) the number of toppings the user would like.
We can only have up to 8 toppings per pizza.
We can have duplicate toppings.
Ask for (and validate) each topping the user would like.
Summarize the users pizza by printing its name, toppings, and total cost.
What variables might you need to create to do this?
If the user does not have any toppings, use the following print statement replacing pizzaName: You have ordered pizzaName with no toppings.
Update any relevant variables for printing the total (t) and reading the users order (r).
Sample interaction (User input in bold):
Welcome to Adkins Pizzeria!
Can I have your name please?
Wilson the Volleyball
Ok, let's start your order, Wilson the Volleyball.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
t
Total $0.00.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
r
You have not ordered any pizzas yet.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
a
What would you like to name pizza number 1?
Hawaiian
What size would you like Hawaiian to be?
We can handle pizzas between 8 and 48 inches.
12
How many toppings would you like on this pizza?
You can have between 0-8 toppings.
2
What topping would you like?
Your options are: Pepperoni, Mushroom, Chicken, Ham, Pineapple, Sausage, Basil, Olive.
Ham
Chosen topping Ham added.
What topping would you like?
Your options are: Pepperoni, Mushroom, Chicken, Ham, Pineapple, Sausage, Basil, Olive.
Pineapple
Chosen topping Pineapple added.
You have ordered Hawaiian with toppings:
Ham, Pineapple.
This pizza costs: $15.65.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
t
Total $15.65.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
r
You ordered the following pizzas:
Hawaiian
Ok, Wilson the Volleyball your total for your 1 pizza will come out to $15.65.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
a
What would you like to name pizza number 2?
Original
What size would you like Original to be?
We can handle pizzas between 8 and 48 inches.
22
How many toppings would you like on this pizza?
You can have between 0-8 toppings.
9
Please choose a number of toppings between 0 and 8.
-1
Please choose a number of toppings between 0 and 8.
1
What topping would you like?
Your options are: Pepperoni, Mushroom, Chicken, Ham, Pineapple, Sausage, Basil, Olive.
pepperoni
Chosen topping pepperoni added.
You have ordered Original with toppings:
pepperoni.
This pizza costs: $41.81.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
r
You ordered the following pizzas:
Hawaiian, Original
Ok, Wilson the Volleyball your total for your 2 pizzas will come out to $57.47.
Here is what you can do next:
MENU
a - Add a pizza
t - Print the total
r - Read the order
q - Quit
Please make a selection:
q
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
