Saturday 9 May 2015

A PROGRAM TO ENABLE USERS TO ORDER PIZZAS ONLINE !!!

/*DO YOU WONDER HOW DO WE ORDER A PIZZA WITH ALL ITS TOPPINGS AND OTHER STARTERS ONLINE??
 * SO HERE IS THE PROGRAM TO DO JUST THAT
 * WELL ,PERSONALLY I BELIEVE THAT IN THE NEAR FUTURE THE WAITERS WOULD BE TAKEN OVER BY MACHINES RUNNING ON PROGRAMS LIKE THESE.
 */ 

My INPUT
   

 import java.util.*;//using Scanner class to take input
    class pizza
    {
        Scanner in = new Scanner(System.in);
        void main()
        {
            System.out.println("Enter the Total Types of Pizzas and Starters in total that  you are going to order");
            int tt  = in.nextInt();
            double price[] = new double[tt ];
            double bill = 0.0 ;
            String top[] = new String[tt ];
            String options[] = new String[tt ];
            int quantity[] = new int[tt ];
            String size[] = new String[tt ];
            int ch , temp = 0 , qty,tp,sz;
            double pr=0.0 ;
            System.out.println("KINDLY ENTER YOUR NAME");
            String nm = in.next();//to input name
            System.out.println("The prices written will simply add to the Total Bill ");
            System.out.println("Kindly enter the NUMBERS written along with the option to select that option");
            System.out.println("Remember if your bill exceeds 100$ we offer you 4% rebate/discount on your bill");
            for(temp= 0 ;temp<tt   ; )
            {
             
            System.out.println("Enter the Type of Pizza You want. ");
            System.out.println(" 1.Veg Treat   2.Special Non Veg   3.Starters  ");
            int op1 = in.nextInt();//to input Choice
            switch (op1)
            {
                case 1:
                System.out.println("Pick your choice");
                System.out.println("1. Veg. Extravaganza[5$]   2. Cloud 9[8$]     3.Paradise[10$]    4.Mexican[12$]   5.Delux[15$]");
                ch = in.nextInt();//to input Choice
               System.out.println("Enter quantity ");
                qty = in.nextInt();
                quantity[temp] = qty ;//to input quantity
                switch (ch)
                {
                    case 1:
                options[temp] = "Veg. Extravaganza     " ;
                price[temp] = 5.0*qty;
                break;
                case 2:
                options[temp] = "Cloud                 ";
                price[temp] = 9.0*qty;
                break;
                case 3:
                options[temp] = "Paradise               " ;
                 price[temp] = 10.0*qty;
                break;
                case 4:
                options[temp] = "Mexican                 " ;
                 price[temp] = 12.0*qty;
                break;
                case 5:
                options[temp] = "Delux                   " ;
                 price[temp] = 15.0*qty;
                break;
            }
                System.out.println("Enter Size of Pizzas");
                System.out.println("1. Regular[5$]   2.Medium[7$]    3.Large[10$]");
                sz = in.nextInt();
              switch (sz)
                {
                    case 1:
                    price[temp] +=5.0;
                    size[temp] = "Regular";
                    break;
                    case 2:
                    price[temp]+=7.0;
                    size[temp] = "Medium";
                    break;
                    case 3:
                    price[temp]+=10.0;
                    size[temp] = "Large";
                    break;
                }
                System.out.println("Enter the toppings you want");
                System.out.println("1. Cheese Burst[5$]    2. Fresh Pan [7$]   3.Classic[10$]       4.Wheat Crust[12$]");
                tp = in.nextInt();
                switch (tp)
                {
                    case 1:
                    price[temp] +=5.0;
                    top[temp] = "Cheese Burst";
                    break;
                    case 2:
                    price[temp]+=7.0;
                    top[temp] = "Fresh Pan ";
                    break;
                    case 3:
                    price[temp]+=10.0;
                    top[temp] = "Classic";
                    break;
                    case 4:
                    price[temp]+=12.0;
                    top[temp] = "Wheat Crust";
                    break;
                }temp++;
         System.out.println("ORDER RECORDED");
           break;
           case 2:
                System.out.println("Pick your choice");
                System.out.println("1. Cheese & BPQ Chicken[7$]  2. Zesty Pork [10$]     3.Golden Delight[13$]    4.Salami special[15$]   5.Hawaiian Twist[18$]");
                ch = in.nextInt();
                System.out.println("Enter quantity ");
                qty = in.nextInt();
                quantity[temp] = qty ;
                switch (ch)
                {
                 case 1:
                options[temp] = "Cheese & BPQ Chicken   " ;
                price[temp] = 7.0*qty;
                break;
                case 2:
                options[temp] = "Zesty Pork           ";
                price[temp] = 10.0*qty;
                break;
                case 3:
                options[temp] = "Golden Delight       " ;
                 price[temp] = 13.0*qty;
                break;
                case 4:
                options[temp] = "Salami special       " ;
                 price[temp] = 15.0*qty;
                break;
                case 5:
                options[temp] = "Hawaiian Twist        " ;
                 price[temp] = 18.0*qty;
                break;
            }
                System.out.println("Enter Size of Pizzas");
                System.out.println("1. Regular[6$]   2.Medium[8$]    3.Large[11$]");
                sz = in.nextInt();
             
                switch (sz)
                {
                    case 1:
                    price[temp] +=6.0;
                    size[temp] = "Regular";
                    break;
                    case 2:
                    price[temp]+=8.0;
                    size[temp] = "Medium";
                    break;
                    case 3:
                    price[temp]+=11.0;
                    size[temp] = "Large";
                    break;
                }
                ;
                System.out.println("Enter the toppings you want");
               System.out.println("1. Cheese Burst[7$]    2. Fresh Pan [9$]   3.Classic[13$]       4.Wheat Crust[15$]");
                tp = in.nextInt();
                switch (tp)
                {
                    case 1:
                    price[temp] +=7.0;
                    top[temp] = "Cheese Burst           ";
                    break;
                    case 2:
                    price[temp]+=9.0;
                    top[temp] = "Fresh Pan             ";
                    break;
                    case 3:
                    price[temp]+=13.0;
                    top[temp] = "Classic              ";
                    break;
                    case 4:
                    price[temp]+=15.0;
                    top[temp] = "Wheat Crust           ";
                    break;
                }
                temp++;
                     System.out.println("ORDER RECORDED");
             break;
            case 3:
                System.out.println("Pick your choice");
                System.out.println("1. Mexican Roll[5$]   2. Coca-cola[8$]   3. Choco Lava Cake[12$]  4. Lemonade[4$] ");
                ch = in.nextInt();
                System.out.println("Enter quantity ");
                qty = in.nextInt();
                quantity[temp] = qty ;
                switch (ch)
                {
                    case 1:
                    price[temp] +=(5.0*qty);
                    options[temp] = "Mexican Roll         ";
                    break;
                    case 2:
                    price[temp]+=(8.0*qty);
                    options[temp] = "Coca-cola             ";
                    break;
                    case 3:
                    price[temp]+=(12.0*qty);
                    options[temp] = "Choco Lava Cake        ";
                    break;
                    case 4:
                    price[temp]+=(8.0*qty);
                    options[temp] = "Lemonade               ";
                    break;
                }
                size[temp]= "N/A";
                top[temp] = "N/A";
            temp++;
            System.out.println("ORDER RECORDED");
            break ;
            default:
            System.out.println("Wrong Choice. Kindly re-enter");
        }
    }
    double disc = 0.0 ;
    for(int j = 0 ; j<tt  ; j++)
    pr = price[j]+pr;
    if(pr>=100.0)
    disc = (0.04)*pr;
    bill = pr-disc;
System.out.println("\n \n \n");
System.out.println("############################# WELCOME TO DOMINOS ############################");
    System.out.println("\n $$$$$$$$$ SO YOUR BILL $$$$$$$$$$$");
    System.out.println();
    System.out.println("PIZZAS ORDERED            QUANTITY        COST       SIZE           TOPPINGS \n ");
    for(int l = 0 ; l<tt  ; l++)//To print the elements of the arrays
    System.out.println(options[l]+"    "+quantity[l]+"          "+price[l]+"         "+size[l]+"           "+top[l]);
    System.out.println("Your Bill = "+pr);
    System.out.println("Your Total Discount = "+disc);
    System.out.println("Your Final Bill = "+bill);
    System.out.println("\n *************THANK YOU***************");
    System.out.println("KINDLY VISIT AGAIN");
    System.out.println();
    System.out.println();
    System.out.println();
    System.out.println("________________________");
    System.out.println("  "+nm);
    System.out.println("         SIGNATURE");
    System.out.println("YOUR ORDER WOULD BE DELIVERED IN 30 MINUTES ");
    System.out.println("\n ********************* HAVE A NICE DAY!!! *************************");
}
}

MY OUTPUT


// PLEASE GIVE SUGGESTIONS AND ASK  QUESTIONS DOWN IN THE COMMENTS SECTION

No comments:

Post a Comment