Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Pizza Pickup and delivery ordering java program

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Pizza Pickup and delivery ordering java program

    This is my code for a Pizza Pickup and delivery um am having a few issues can someone please give me a hand.
    thank you

    public class Internal{
    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 pizzaChoice1 =0;
    int pizzaChoice2 =0;
    int pizzaChoice3 =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]);
    }
    pizzaChoice1 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice1] + " pizzas do you wish to buy (Maximum is 5)");
    totalPizza = totalPizza + pizzaQuantity;
    if(totalPizza > max)

    pizzaChoice2 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice2] + " pizzas do you wish to buy (Maximum is 5)");
    totalPizza = totalPizza + pizzaQuantity;
    if(totalPizza > max)

    pizzaChoice3 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice3] + " 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");
    pizzaChoice1 = 0;
    pizzaChoice2 = 0;
    pizzaChoice3 = 0;
    pizzaQuantity = 0;
    }
    else
    {
    orderDisplay[pizzaChoice1] = pizzaQuantity;
    orderDisplay[pizzaChoice2] = pizzaQuantity;
    orderDisplay[pizzaChoice3] = pizzaQuantity;
    }
    done= readInt ("Press 0 if you are done or press 1 to make another pizza order");
    double total1 = pizzaQuantity*pizzaPrice[pizzaChoice1];

    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 = 3;
    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));
    }
    }

    cheers pointblank


  2. #2
    Junior Member
    Join Date
    Mar 2014
    Location
    Denmark, Albertslund
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Pizza Pickup and delivery ordering java program

    Can you plzz write the error

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Pizza Pickup and delivery ordering java program

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags which are explained near the top of the link above. As magnus pointed out, you also need to post errors you need help with or ask specific questions. We typically won't debug your code for you, but we'll help you debug your code.

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pizza Pickup and delivery ordering java program

    pizzaChoice1 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice1] + " pizzas do you wish to buy (Maximum is 5)");
    totalPizza = totalPizza + pizzaQuantity;
    if(totalPizza > max)

    pizzaChoice2 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice2] + " pizzas do you wish to buy (Maximum is 5)");
    totalPizza = totalPizza + pizzaQuantity;
    if(totalPizza > max)

    pizzaChoice3 = readInt ("Choose the type of pizza you wish to order");
    int pizzaQuantity = readInt ("How many " + pizzaType[pizzaChoice3] + " pizzas do you wish to buy (Maximum is 5)");
    totalPizza = totalPizza + pizzaQuantity;
    if(totalPizza > max)

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Pizza Pickup and delivery ordering java program

    Those are not errors. You have just reposted a section of your code. When you compile your code it spits out one or more errors. Copy and paste them here. Also post #3 provided a link how to post formatted code. Clearly you did not read it. If you cannot be bothered to do this and make our task easier why should we be bothered to help you?
    Improving the world one idiot at a time!

Similar Threads

  1. java program codes for fast food ordering system
    By lubxter in forum Object Oriented Programming
    Replies: 2
    Last Post: October 7th, 2013, 10:36 PM
  2. java program codes for fast food ordering system
    By harleypogi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 1st, 2013, 04:42 AM
  3. java program codes for fast food ordering system
    By jeasay in forum Java Theory & Questions
    Replies: 1
    Last Post: July 20th, 2013, 11:52 PM
  4. java pizza program beginerr
    By nikki101 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 17th, 2013, 03:22 AM
  5. Help with pickup stones game
    By booti in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 3rd, 2011, 12:54 PM