Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:01:50+00:00 2026-06-04T03:01:50+00:00

public class PizzaExamfinalOne{ public static void main(String[]args){ double total2 = 0; String customerName =

  • 0
public class PizzaExamfinalOne{
  public static void main(String[]args){
    double total2 = 0;
    String customerName = " ";
    String address = " ";
    String phoneNum ="0";
    int max = 5;
    int done = 1;
    double totalPizza = 0;
    double totalA = 0;

    int pizzaChoice =0;

    String [] pizzaType = {"Placeholder",  "Hawaian" , "Classic Italian" , "Cheese Extreme" , "Veg Delight" , "Pepperoni" , "Tomato Margherita" , "Beef & Onion" , "Super Supreme" , "Meat Lovers" , "Hot 'n Spicy" , "Italiano" , "Italian Veg"};
    double [] pizzaPrice = {0, 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 13.5 , 13.5 , 13.5 , 13.5 , 13.5};
    int [] orderDisplay = {0,0,0,0,0,0,0,0,0,0,0,0,0};

    boolean pickup = true;
    int pickup1 = readInt("If you wish to pickup press 1 or  press 0 for delivery");
    if (pickup1 ==0){
      pickup = false;
    }

    for (int i = 1; i <pizzaType.length; i++){
      System.out.println(i + " " +pizzaType[i] + " $" + pizzaPrice[i]);
    }

    while (done !=0){

      pizzaChoice = readInt ("Choose the type of pizza you wish to order");
      double pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice] + " pizzas do you wish to buy (Maximum is 5)");   

      totalPizza = totalPizza + pizzaQuantity;
      if(totalPizza > max){
        System.out.println("You cannot order more than five pizzas");
        pizzaChoice = 0;  
        pizzaQuantity = 0;
      }

      done= readInt ("Press 0 if you are done or press 1 to make another pizza order");
      double total1 = pizzaQuantity*pizzaPrice[pizzaChoice];
      total2 = total2 + total1;

    }

    if(pickup==false){
      int deliveryCost = 3;
      customerName = readString ("Please enter your full name");
      address = readString ("Please enter the Delivery address");
      phoneNum = readString ("Please enter the phone number of " + customerName);
      totalA = total2 + deliveryCost;
      System.out.println("Delivery order for " + customerName);
      System.out.println("To " + address + ", Phone number 0" + phoneNum);

    }
      else{
      customerName = readString ("Please enter your full name");
      System.out.println("Pickup order for " + customerName);
      int deliveryCost = 0;
      totalA = total2 + deliveryCost;

    }

My problem is here. I need to display the pizzas that the user has ordered along with the amount of pizzas ordered and I’m stuck here. there are no errors in the code it just doesnt display the following

    for(int i=1;i<orderDisplay.length;i++){
      if(orderDisplay[i]>0){
        System.out.println("       " + orderDisplay[i] +  " " + pizzaType[i] + " pizzas");
      }
    }
    System.out.println("The total amount of your order is " + formatMoney(totalA));
  }


  public static int readInt(String prompt){
    System.out.println(prompt);
    java.util.Scanner keyboard = new java.util.Scanner(System.in);                                
    return keyboard.nextInt();
  }
  public static String readString (String prompt){
    System.out.println (prompt);
    java.util.Scanner keyboard= new java.util.Scanner(System.in);
    return keyboard.nextLine();
  }

  public static String formatMoney(double phoneNum){
    java.text.NumberFormat  fmt = java.text.NumberFormat. getCurrencyInstance();
    return(fmt.format(phoneNum));
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:01:52+00:00Added an answer on June 4, 2026 at 3:01 am

    You have set all the array elements of orderDisplay to 0.

    int [] orderDisplay = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    

    U never changed the value of orderDispaly elements and checking for value greater than 0 and u have started your loop with value 1. check the below lines.

     for(int i=1;i<orderDisplay.length;i++){
          if(orderDisplay[i]>0){
            System.out.println("       " + orderDisplay[i] +  " " + pizzaType[i] + " pizzas");
          }
    

    Here is your answer :

    public class PizzaExamFinalOne
    {
        public static void main(String[]args)
        {
            double total2 = 0;
            String customerName = " ";
            String address = " ";
            String phoneNum ="0";
            int max = 5;
            int done = 1;
            double totalPizza = 0;
            double totalA = 0;
            int pizzaChoice =0;
            String [] pizzaType = {"Placeholder",  "Hawaian" , "Classic Italian" , "Cheese Extreme" , "Veg Delight" , "Pepperoni" , "Tomato Margherita" , "Beef & Onion" , "Super Supreme" , "Meat Lovers" , "Hot 'n Spicy" , "Italiano" , "Italian Veg"};
            double [] pizzaPrice = {0, 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 8.5 , 13.5 , 13.5 , 13.5 , 13.5 , 13.5};
            int [] orderDisplay = {0,0,0,0,0,0,0,0,0,0,0,0,0};
            boolean pickup = true;
            int pickup1 = readInt("If you wish to pickup press 1 or  press 0 for delivery");
            if (pickup1 == 0)
            {
                pickup = false;
            }
            while (done != 0)
            {
                for (int i = 1; i <pizzaType.length; i++)
                {
                    System.out.println(i + " " +pizzaType[i] + " $" + pizzaPrice[i]);
                }
                pizzaChoice = readInt ("Choose the type of pizza you wish to order");
                int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice] + " pizzas do you wish to buy (Maximum is 5)");
                totalPizza = totalPizza + pizzaQuantity;            
                if(totalPizza > max)
                {
                    totalPizza = totalPizza - pizzaQuantity;
                    System.out.println("You cannot order more than five pizzas");
                    pizzaChoice = 0;  
                    pizzaQuantity = 0;
                }
                else
                {
                    orderDisplay[pizzaChoice] = pizzaQuantity;
                }
                done= readInt ("Press 0 if you are done or press 1 to make another pizza order");
                double total1 = pizzaQuantity*pizzaPrice[pizzaChoice];
                total2 = total2 + total1;
            }
            if(totalPizza > 0)
            {
                if(pickup == false)
                {
                    int deliveryCost = 3;
                    customerName = readString ("Please enter your full name");
                    address = readString ("Please enter the Delivery address");
                    phoneNum = readString ("Please enter the phone number of " + customerName);
                    totalA = total2 + deliveryCost;
                    System.out.println("Delivery order for " + customerName);
                    System.out.println("To " + address + ", Phone number 0" + phoneNum);
                }
                else
                {
                    customerName = readString ("Please enter your full name");
                    System.out.println("Pickup order for " + customerName);
                    int deliveryCost = 0;
                    totalA = total2 + deliveryCost;
                }
                for(int i=1;i<orderDisplay.length;i++)
                {
                    if(orderDisplay[i]>0)
                    {
                        System.out.println("       " + orderDisplay[i] +  " " + pizzaType[i] + " pizzas");
                    }
                }
                System.out.println("The total amount of your order is " + formatMoney(totalA));
            }
            else
            {
                System.out.println("You have not ordered anything.");
            }
        }
        public static int readInt(String prompt)
        {
            System.out.println(prompt);
            java.util.Scanner keyboard = new java.util.Scanner(System.in);                                
            return keyboard.nextInt();
        }
        public static String readString (String prompt)
        {
            System.out.println (prompt);
            java.util.Scanner keyboard= new java.util.Scanner(System.in);
            return keyboard.nextLine();
        }
    
        public static String formatMoney(double phoneNum)
        {
            java.text.NumberFormat  fmt = java.text.NumberFormat. getCurrencyInstance();
            return(fmt.format(phoneNum));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Employee { public static void main(String[] args) { int j=3; staples[] stemp
public class Demo { public static void main(String args[]) { double d = 12.345;
public class Main { public static void main (String args[]) { int nums[]= {2,
public class InterruptedInput { public static void main(String[] args) { InputThread th=new InputThread(); //worker
public class Test { public static void main(String[] args) { } } class Outer
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
public class Test { public static void main(String[] args) throws Exception { String s1
public class Main { public static void main(String[] args) throws InterruptedException { ClassA a
public class Guess { public static void main(String[] args){ <sometype> x = <somevalue>; System.out.println(x
public class Anagram { public static void main(String[] args) { String a = Despera

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.