Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For my program it is call pizza order and I am having trouble figuring out how to add a code to add multiple toppings with

For my program it is call pizza order and I am having trouble figuring out how to add a code to add multiple toppings with out using arrays, code is below.

import java.util.Scanner;

public class PizzaOrder { public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); double orderTotal = 0.0; System.out.println("How many pizzas do you want to order today?"); int numPizzas = keyboard.nextInt(); for (int i = 1; i <= numPizzas;i++){ System.out.println("Pizzas " + i + ":"); System.out.println("What size would you like? (Small,Medium,Large)"); String size = keyboard.next(); double sizePrice = 0.0; if (size.equalsIgnoreCase("Small")){ sizePrice = 8.0; }else if (size.equalsIgnoreCase("Medium")){ sizePrice = 12.0; }else if (size.equalsIgnoreCase("Large")){ sizePrice = 16.0; } System.out.println("What is your crust preference? (Regular, Thin, Pan Stuffed)"); String crust = keyboard.next(); double crustPrice = 0.0; if (crust.equalsIgnoreCase("thin")){ crustPrice = 2.0; }else if(crust.equalsIgnoreCase("pan")){ crustPrice = 3.0; }else if(crust.equalsIgnoreCase("stuffed")){ crustPrice = 3.5; } System.out.println("Do you want to add Double cheese, enter y for yes: ");//, Pepperoni, Sausage, Mushrooms, Spinach )"); String toppings = keyboard.next(); double toppingsPrice = 0.0; if(toppings.equalsIgnoreCase("y")){ toppingsPrice += 1.0; } if(toppings.equalsIgnoreCase("no" )){ toppingsPrice += 2.0; } System.out.println("What toppings would you like? (Double cheese, Pepperoni, Sausage, Mushrooms, Spinach )"); toppings = keyboard.next(); if(toppings.equalsIgnoreCase("pepperoni")){ toppingsPrice += 2.0; } double pizzaPrice = sizePrice + crustPrice + toppingsPrice; System.out.println("Pizza" +i+":" +size+ ""+crust+ "crust with" +toppings+ "-$" +pizzaPrice); orderTotal += pizzaPrice; } System.out.println("Number of pizzas ordered: "+numPizzas); System.out.println("Order total: $" + orderTotal); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago