import javax.swing.*;

import java.util.*;

import java.text.*;


class myjavalo{

    public static void main (String []args) {

      String orderStr1, orderStr2, orderStr3;

      int order1, order2, order3, choice;

      int i = 0;

      int menuCat,Entree, SideDish, Drink;

     System.out.println("\tItem" + "\t\t\tSales Count" + "\t\t\tTotal");

     do{


    Entree = Integer.parseInt (JOptionPane.showInputDialog (null, "Your Options Are:1 - Tofu Burger $3.49 2 - Cajun Chicken #4.59 3 - Buffalo Wings $3.99 4 - Rainbow Fillet $2.99"));

    SideDish = Integer.parseInt (JOptionPane.showInputDialog (null, "Your Options Are:5 - Rice Cracker - $0.79 6 - No-Salt Fries - $0.69 7 - Zucchini - $1.09 8 - Brown Rice - $0.59"));


  Drink = Integer.parseInt (JOptionPane.showInputDialog (null, "Enter Drink Number: 9 Cafe Mocha - $1.99 10 Cafe Latte - $1.99 11 Espresso - $2.49 12 Oolong Tea - $0.99"));

       Menu menu = new Menu (Entree, SideDish, Drink);

      choice = Integer.parseInt(JOptionPane.showInputDialog(("New customer?\n1 = yes\n2 = no")));

      i++;

      } while (choice == 1);
          System.exit(0);





    }


}
class Menu{

private int entree;

    private int sideDish;

    private int drink;

    private double entreePrice;

    private double sideDishPrice;

    private double drinkPrice;
    private double totalPrice;

    int tofu, cajun, buffalo, rainbow, rice, noSalt, zucchini, brown, mocha, latte, espresso, oolong;

    public 	Menu (int entreeNumber, int sideDishNumber, int drinkNumber) {

            entree = entreeNumber;
            sideDish = sideDishNumber;

            drink = drinkNumber;

            totalPrice = 0;


    }



    public double getTotal () {


            switch (entree) {


                    case 1: entreePrice = 3.49;


                    break;


                    case 2: entreePrice = 4.59;


                    break;



                    case 3: entreePrice = 3.99;


                    break;


                    case 4: entreePrice = 2.99;

                    break;

                    default: entreePrice = 0;

                    break;


            }




            switch (sideDish) {

                    case 1: sideDishPrice = 0.79;
                    break;
                 case 2: sideDishPrice = 0.69;


                    break;

                    case 3: sideDishPrice = 1.09;


                    break;


                    case 4: sideDishPrice = 0.59;


                    break;



                    default: sideDishPrice = 0;

            }



            switch (drink) {


                    case 1: drinkPrice = 1.99;
           break;



                    case 2: drinkPrice = 1.99;



                    break;


                    case 3: drinkPrice = 2.49;

                    break;


                    case 4: drinkPrice = 0.99;

                    break;



                    default: drinkPrice = 0;

                 break;



            }



            totalPrice = entreePrice + sideDishPrice + drinkPrice;


            return totalPrice;


    }


    public String toString(){


            String message = "";

            String message2 = "";

            String message3 = "";


            String finalReturn;

            if (entree == 1){

                    tofu++;

                    message += "Tofu Burger\n";

            } else if (entree == 2){
                    cajun++;

                    message += "Cajun Chicken\n";

         } else if (entree == 3){



                    buffalo++;

                   message += "Buffalo Wings\n";


            } else if (entree == 4){

                    rainbow++;


                   message += "Rainbow Fillet\n";

            }

        if (sideDish == 5){



                    rice++;


                    message2 += "Rice Cracker\n";

            } else if (sideDish == 6){



                    noSalt++;


                   message2 += "No-Salt Fries\n";


            } else if (sideDish == 7){


                    zucchini++;



                   message2 += "Zucchini\n";


            } else if (sideDish ==8){


                    brown++;



                    message2 += "Brown Rice\n";


            }


            if (drink == 9){


                    mocha++;
              message3 += "Cafe Mocha\n";


            } else if (drink == 10){


                    latte++;


                   message3 += "Cafe Latte\n";


            } else if (drink == 11){

                    espresso++;


                    message3 += "Espresso\n";

            } else if (drink == 12){


                  oolong++;


                 message3 += "Oolong Tea\n";

            }

            finalReturn = message + "\n" + message2 + "\n" +message3;
            return finalReturn;

    }

}

how can i make a count and array?

i need help with the final output that displays the total sales count, total, and items. I was thinking about using a for loop but im clueless as to how i would incorporate it into my program

For the total sales count, total, and items create a counter where a value is added for every user input.

I was thinking about using a for loop but im clueless as to how i would incorporate it into my program

It's hard to imagine how you want the program to look like when you execute it...
Could post when should it display the total sales count, total, and items and how many times it should be displayed?

Edited 4 Years Ago by zeroliken: n/a

I Just needd the like this

Iteam sales count Total
Tofu Burger 25 $87.25
Cajun Chicken 30 $137.70
.......
Today`s Total Sales : $ 2761.20

Edited 4 Years Ago by umsungun: n/a

For the total sales count, total, and items create a counter where a value is added for every user input.

It's hard to imagine how you want the program to look like when you execute it...
Could post when should it display the total sales count, total, and items and how many times it should be displayed?

I Just needd the like this

Iteam sales count Total
Tofu Burger 25 $87.25
Cajun Chicken 30 $137.70
.......
Today`s Total Sales : $ 2761.20

For the total sales count, total, and items create a counter where a value is added for every user input.

It's hard to imagine how you want the program to look like when you execute it...
Could post when should it display the total sales count, total, and items and how many times it should be displayed?

please help me

...


import javax.swing.*;

import java.util.*;

import java.text.*;


class myjavalo{

    public static void main (String []args) {

      String orderStr1, orderStr2, orderStr3;

      int order1, order2, order3, choice;

      int i = 0;

      int menuCat,Entree, SideDish, Drink;

     System.out.println("\tItem" + "\t\t\tSales Count" + "\t\t\tTotal");

     do{


    Entree = Integer.parseInt (JOptionPane.showInputDialog (null, "Your Options Are:1 - Tofu Burger $3.49 2 - Cajun Chicken #4.59 3 - Buffalo Wings $3.99 4 - Rainbow Fillet $2.99"));

    SideDish = Integer.parseInt (JOptionPane.showInputDialog (null, "Your Options Are:5 - Rice Cracker - $0.79 6 - No-Salt Fries - $0.69 7 - Zucchini - $1.09 8 - Brown Rice - $0.59"));


  Drink = Integer.parseInt (JOptionPane.showInputDialog (null, "Enter Drink Number: 9 Cafe Mocha - $1.99 10 Cafe Latte - $1.99 11 Espresso - $2.49 12 Oolong Tea - $0.99"));

       Menu menu = new Menu (Entree, SideDish, Drink);

      choice = Integer.parseInt(JOptionPane.showInputDialog(("New customer?\n1 = yes\n2 = no")));

      i++;

      } while (choice == 1);
          System.exit(0);





    }


}
class Menu{

private int entree;

    private int sideDish;

    private int drink;

    private double entreePrice;

    private double sideDishPrice;

    private double drinkPrice;
    private double totalPrice;

    int tofu, cajun, buffalo, rainbow, rice, noSalt, zucchini, brown, mocha, latte, espresso, oolong;

    public 	Menu (int entreeNumber, int sideDishNumber, int drinkNumber) {

            entree = entreeNumber;
            sideDish = sideDishNumber;

            drink = drinkNumber;

            totalPrice = 0;


    }



    public double getTotal () {


            switch (entree) {


                    case 1: entreePrice = 3.49;


                    break;


                    case 2: entreePrice = 4.59;


                    break;



                    case 3: entreePrice = 3.99;


                    break;


                    case 4: entreePrice = 2.99;

                    break;

                    default: entreePrice = 0;

                    break;


            }




            switch (sideDish) {

                    case 1: sideDishPrice = 0.79;
                    break;
                 case 2: sideDishPrice = 0.69;


                    break;

                    case 3: sideDishPrice = 1.09;


                    break;


                    case 4: sideDishPrice = 0.59;


                    break;



                    default: sideDishPrice = 0;

            }



            switch (drink) {


                    case 1: drinkPrice = 1.99;
           break;



                    case 2: drinkPrice = 1.99;



                    break;


                    case 3: drinkPrice = 2.49;

                    break;


                    case 4: drinkPrice = 0.99;

                    break;



                    default: drinkPrice = 0;

                 break;



            }



            totalPrice = entreePrice + sideDishPrice + drinkPrice;


            return totalPrice;


    }


    public String toString(){


            String message = "";

            String message2 = "";

            String message3 = "";


            String finalReturn;

            if (entree == 1){

                    tofu++;

                    message += "Tofu Burger\n";

            } else if (entree == 2){
                    cajun++;

                    message += "Cajun Chicken\n";

         } else if (entree == 3){



                    buffalo++;

                   message += "Buffalo Wings\n";


            } else if (entree == 4){

                    rainbow++;


                   message += "Rainbow Fillet\n";

            }

        if (sideDish == 5){



                    rice++;


                    message2 += "Rice Cracker\n";

            } else if (sideDish == 6){



                    noSalt++;


                   message2 += "No-Salt Fries\n";


            } else if (sideDish == 7){


                    zucchini++;



                   message2 += "Zucchini\n";


            } else if (sideDish ==8){


                    brown++;



                    message2 += "Brown Rice\n";


            }


            if (drink == 9){


                    mocha++;
              message3 += "Cafe Mocha\n";


            } else if (drink == 10){


                    latte++;


                   message3 += "Cafe Latte\n";


            } else if (drink == 11){

                    espresso++;


                    message3 += "Espresso\n";

            } else if (drink == 12){


                  oolong++;


                 message3 += "Oolong Tea\n";

            }

            finalReturn = message + "\n" + message2 + "\n" +message3;
            return finalReturn;

    }

}

how can i make a count and array?

Edited 4 Years Ago by umsungun: n/a

This article has been dead for over six months. Start a new discussion instead.