Question: I need someone to look at my pizza program, and assist me in why my program is failing. import java.util.Scanner; import java.text.DecimalFormat; public class PizzaOrder

I need someone to look at my pizza program, and assist me in why my program is failing.

import java.util.Scanner;

import java.text.DecimalFormat;

public class PizzaOrder

{

public static void main (String [] args)

{

Scanner keyboard = new Scanner (System.in);

PizzaOrder order = new PizzaOrder ();

String firstName;

boolean discount = false;

int inches;

char crustType;

double cost;

final double TAX_RATE = .08;

double tax;

char choice;

String input;

String toppings = "Cheese ";

int numberOfToppings = 0;

System.out.println("Welcome to Ivan and " + "Carlos Pizzeria");

System.out.print("Enter your first name: ");

firstName = keyboard.nextLine();

//TASK #1

if ( (firstName.equalsIgnoreCase("Carlos")) || (firstName.equalsIgnoreCase("Carlitos")) || (firstName.equalsIgnoreCase("Diana")) )

{

discount = true;

}

System.out.println("Pizza Size (inches) Cost");

System.out.println(" 10 $10.99");

System.out.println(" 12 $12.99");

System.out.println(" 14 $14.99");

System.out.println(" 16 $16.99");

System.out.println("What size pizza would you like?");

System.out.print("10, 12, 14, or 16 " + "(enter the number only): ");

inches = keyboard.nextInt();

if (inches == 10)

{ order.setCost(-2); }

else if (inches == 14)

{ order.setCost(+2); }

else if (inches == 16)

{ order.setCost(+4); }

keyboard.nextLine();

System.out.println("What type of crust do you want? ");

System.out.print("(H)Hand-tossed, (T) Thin-crust, or (D) Deep-dish (enter H, T, or D): ");

input = keyboard.nextLine();

crustType = Character.toUpperCase(input.charAt(0));

switch (crustType)

{

case 'H': order.setCrust("Hand-tossed"); break;

case 'D': order.setCrust("Deep-dish"); break;

case 'T': order.setCrust("Thin-crust"); break;

default: order.setCrust("Invalid selection: Using Hand-tossed"); break;

}

System.out.println("All pizzas come with cheese.");

System.out.println("Additional toppings are $1.25 each, choose from: ");

System.out.println("Pepperoni, Sausage, Onion, Mushroom");

System.out.print("Do you want Pepperoni? (Y/N): ");

input = keyboard.nextLine();

choice = Character.toUpperCase(input.charAt(0));

if (choice == 'Y')

{

numberOfToppings += 1;

toppings = toppings + "Pepperoni ";

}

System.out.print("Do you want Sausage? (Y/N): ");

input = keyboard.nextLine();

choice = Character.toUpperCase(input.charAt(0));

if (choice == 'Y')

{

numberOfToppings += 1;

toppings = toppings + "Sausage ";

}

System.out.print("Do you want Onion? (Y/N): ");

input = keyboard.nextLine();

choice = Character.toUpperCase(input.charAt(0));

if (choice == 'Y')

{

numberOfToppings += 1;

toppings = toppings + "Onion ";

}

System.out.print("Do you want Mushroom? (Y/N): ");

input = keyboard.nextLine();

choice = Character.toUpperCase(input.charAt(0));

if (choice == 'Y')

{

numberOfToppings += 1;

toppings = toppings + "Mushroom ";

}

order.setNumToppings(numberOfToppings);

order.setToppingList(toppings);

order.setCost(1.25*numberOfToppings);

System.out.println();

System.out.println("Your order is as follows: ");

System.out.println(order.getSize() + " inch pizza");

System.out.println(order.getCrust() + " crust");

System.out.println(order.getToppingList());

cost = order.getCost();

if (discount == true)

{

System.out.println("You get a discount!");

order.setCost(-2);

cost = order.getCost();

}

DecimalFormat df = new DecimalFormat("##.00");

System.out.println("The cost of your order is: $" + df.format(cost));

tax = (cost * TAX_RATE);

System.out.println("The tax is: $" + df.format(tax));

System.out.println("The total due is: $" + df.format((tax+cost)));

System.out.println("Your order will be ready for pickup in 30 minutes.");

}

private String getSize() {

return null;

}

private String getCrust() {

return null;

}

private char[] getToppingList() {

return null;

}

private double getCost() {

return 0;

}

private void setNumToppings(int numberOfToppings) {

}

private void setToppingList(String toppings) {

}

private void setCrust(String string) {

}

private void setCost(double d) {

}

}

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!