Question: In Java, using methods and arrays can someone help me right a code going through each menu item, while updating the price as the order

In Java, using methods and arrays can someone help me right a code going through each menu item, while updating the price as the order continues. there is a sample interaction below

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).

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).

Constants (these have changed since last iteration):

cheese cost per square inch: 0.0272;

sauce cost per square inch: 0.0316;

dough cost per square inch: 0.0228;

topping cost per square inch: 0.0284;

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: $6.42.

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: $10.80.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!