Home Robotics C++ Physics II AP Physics B Electronics AP Java Astronomy Independent Study Summer Session Contests  About
                                                       

import javax.swing.*;

public class ExplainerProblem

{

      //4 instance variables

      private static double CokeCost = 1.29;

      private static double FriesCost = 2.39;

      private static double BurgerCost = 3.49;

      private static double TaxRate = 1.08;

 

      public static void main(String[] args)

 

      {

            Greeting();  //Call method to greet the customer

            announceMenu();   //Call method to announce menu

            int CokesOrder = getNumberCokes();  //call method to get number of cokes wanted

            int FriesOrder = getNumberFries();  //call method to get number of fries wanted

            int BurgersOrder = getNumberBurgers();  //call method to get number of burgers wanted

            double TotalBill = calculateTotalBill(CokesOrder, FriesOrder, BurgersOrder); //call method to find total bill

            announcePrice(TotalBill);  //call method to announce total bill

      }

      public static void Greeting()  //Provide greeting

      {

        JOptionPane.showMessageDialog(null, "Welcome to my Restaurant", "Greeting", JOptionPane.PLAIN_MESSAGE);

      }

      public static void announceMenu()    //Give the menu

      {

        JOptionPane.showMessageDialog(null, "The cost of a coke is :" + CokeCost, "Cost of Cokes ", JOptionPane.PLAIN_MESSAGE);

        JOptionPane.showMessageDialog(null, "The cost of an order of fries is : " + FriesCost, "Cost of Fries", JOptionPane.PLAIN_MESSAGE);    

        JOptionPane.showMessageDialog(null, "The cost of a burger is : " + BurgerCost, "Cost of Burgers", JOptionPane.PLAIN_MESSAGE);

        JOptionPane.showMessageDialog(null, "The tax rate is :" + TaxRate, "Tax Rate ", JOptionPane.PLAIN_MESSAGE);

      }

      public static int getNumberCokes()    //Method to get number of cokes

      {

            String cokesIn;

            int NumCokes;

            cokesIn = JOptionPane.showInputDialog("How many cokes do you want?");

            NumCokes = Integer.parseInt(cokesIn);

            return NumCokes;

      }

      public static int getNumberFries()     //Method to get number of fries

      {

            String friesIn;

            int Numfries;

            friesIn = JOptionPane.showInputDialog("How many fries do you want?");

            Numfries = Integer.parseInt(friesIn);

            return Numfries;

       }

       public static int getNumberBurgers()   //Method to get number of burgers

       {

            String burgersIn;

            int Numburgers;

            burgersIn = JOptionPane.showInputDialog("How many cheese-burgers do you want?");

            Numburgers = Integer.parseInt(burgersIn);

            return Numburgers;

       }

       //Method to calculate the total bill

       public static double calculateTotalBill(int CokesOrder, int FriesOrder, int BurgersOrder)

       {

               double bill;

               bill = (CokesOrder*CokeCost + FriesOrder*FriesCost + BurgersOrder*BurgerCost)*TaxRate;

               return bill;

       }

       //Method to announce total bill

       public static void announcePrice(double TotalBill)

       {

         JOptionPane.showMessageDialog(null, "The total bill is: " + TotalBill, "The Bill", JOptionPane.PLAIN_MESSAGE);

         JOptionPane.showMessageDialog(null,"Come back tomorrow and pick up the order", "Order Delay", JOptionPane.PLAIN_MESSAGE);

       }             

}