Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need this program solved in java to study please....I use jgrasp Ice Cream Ord

ID: 3692530 • Letter: I

Question

I need this program solved in java to study please....I use jgrasp

Ice Cream Order Program Create a Java GUI class named IceCreamOrder that helps you to determine the cost of one ice cream order. The application should have the following appearance Your Name Ice Cream Order Icecream Flavor Extras Process Vanill Chocolate O Strawberry Nuts Cherries Restore Save Calculate Cost The user can select flavor and any number of extras. When they press the Calculate Cost button, then a dialog box with the following style of content it presented to the user: X Your Name Ice Cream Order Icecream Flavor Extras Process Vanilla Chocolate C) Strawberry LZ Nuts Cherries Restore Save Calculate Cost Message YOUR ORDER Cost: 3.25 Tax: 0.20 Total: 3.45 OK All ice cream flavors are $2.25. Each extra is 0.50. So, the in the example above, the cone is 2.25, nuts are 0.50 and cherries are 0.50, for a total of 3.25. The Michigan 6% tax is added on for a total of 3.45 One specific order can be saved at any time. When an order is saved, the information stored on the disk is the flavor and the extras. The file should be named icecream.txt, and the file will always have exactly three lines of text, of the general format Flavor Nuts Status Cherries Status The first line is either "Vanilla", "Chocolate" or "Strawberry". The second line is always "With_Nuts" or "Without_Nuts". The third line is always "With Cherries" or "Without Cherries"

Explanation / Answer

//importing packages

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.text.DecimalFormat;

import java.io.*;`

//IceCream.java

public class IceCream extends JFrame

{

//Constants for window width and height

   private final int WINDOW_WIDTH = 500;

   private final int WINDOW_HEIGHT = 250;

//Ice cream flavors

   private JRadioButton bVan; //Vanilla Radio button

   private JRadioButton bStraw; //Strawberry Radio button

   private JRadioButton bChoc; //Chocolate radio button

   //Nuts

   private JCheckBox cbNuts; //Checkbox for Nuts

   private JCheckBox cbCherr; //Checkbox for Cherries

   //Syrup

   private JRadioButton bChocSyrup; //Radio button for Chocolate syrup

   private JRadioButton bCaramSyrup; //Radio button for Caramel syrup

   private JRadioButton bNoSyrup; //Radio button for No syrup

   //Buttons for Open, Save and Close features.

   private JButton Save;

   private JButton Open;

   private JButton Total;

//Button Groups for Ice Cream flavors and Syrup flavors

   private ButtonGroup iceCreamGroup;

   private ButtonGroup syrupGroup;

//Panels for the button groups

   private JPanel iceCreamPanel; //IceCream flavor Panel

   private JPanel nutsPanel; //Nuts or no nuts panel

   private JPanel syrupPanel; //Syrup flavors panel

   private JPanel buttonPanel; //Panel for Save, Open, and Total buttons

//CONSTRUCTOR  

   public IceCream()  

   {   

   //Window title

      setTitle("Icecream Orders");

   //Set size

      setSize(WINDOW_WIDTH,WINDOW_HEIGHT);

//Default close operation

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  

   //Calling buildPanel method

      buildPanels();

setLayout(new GridLayout(2,2));

      //Adding the panel to JFrame

      add(iceCreamPanel);

      add(nutsPanel);

      add(syrupPanel);

      add(buttonPanel);

    //Visibility

      setVisible(true);

}

   private void buildPanels()

   {

      //Initializing the flavor radio butons and adding them to the Buton Group

      bVan = new JRadioButton("Vanilla", true);

      bStraw = new JRadioButton("Strawberry");

      bChoc = new JRadioButton("Chocolate");

   iceCreamGroup = new ButtonGroup();

      iceCreamGroup.add(bVan);

      iceCreamGroup.add(bStraw);

      iceCreamGroup.add(bChoc);

      //Initializing the Checkbox for nuts and cherries

      cbNuts = new JCheckBox("Nuts?");

      cbCherr = new JCheckBox("Cherries?");

      //Initializing the Syrup radio buttons and adding them to the Button Group

      bChocSyrup = new JRadioButton("Chocolate", true);

      bCaramSyrup = new JRadioButton("Caramel");

      bNoSyrup = new JRadioButton("None");

    syrupGroup = new ButtonGroup();

      syrupGroup.add(bChocSyrup);

      syrupGroup.add(bCaramSyrup);

      syrupGroup.add(bNoSyrup);

  //Initializing the Buttons

      Save = new JButton("Save Order");

      Open = new JButton("Open Order");

      Total = new JButton("Total");

      //Associating action listener to the total button

      Total.addActionListener(new TotalButtonListener());

   //Initializing the panels

      iceCreamPanel = new JPanel();

      nutsPanel = new JPanel();

      syrupPanel = new JPanel();

      buttonPanel = new JPanel();

//Setting borders of the panels

      iceCreamPanel.setBorder(BorderFactory.createTitledBorder("Ice Cream Flavor"));

      nutsPanel.setBorder(BorderFactory.createTitledBorder("Nuts?"));

      syrupPanel.setBorder(BorderFactory.createTitledBorder("Syrup Flavor"));

  //Adding the objecs to the respective panels

      iceCreamPanel.add(bVan);

      iceCreamPanel.add(bStraw);

      iceCreamPanel.add(bChoc);

    nutsPanel.add(cbNuts);

      nutsPanel.add(cbCherr);

      syrupPanel.add(bChocSyrup);

      syrupPanel.add(bCaramSyrup);

      syrupPanel.add(bNoSyrup);

        buttonPanel.add(Save);

      buttonPanel.add(Open);

      buttonPanel.add(Total);

   }//End buildPanels

private class TotalButtonListener implements ActionListener

   {

      public void actionPerformed(ActionEvent e)

      {

         double total = 1.5;

         //Creating a new deciaml format using DecimalFormater

         DecimalFormat formatter = new DecimalFormat("##.##");

         //Calculating total price using .isSelcted method

         if(cbNuts.isSelected())

           total += 0.75;

      if(cbCherr.isSelected())

           total += 0.50;

         if(bChocSyrup.isSelected())

            total += 0.75;

      if(bCaramSyrup.isSelected())

            total += 0.75;   

         //Calculating sales tax

         double tax = total * 0.06;

JOptionPane.showMessageDialog(null, "Total: $" + (formatter.format(total + tax)) +

                                    " ($" + formatter.format(total) + " + $"

                                     + formatter.format(tax) + " tax)");

} //End actionPermormed

   } //End TotalButtonListener      

   //Embedded Main method

   public static void main(String[] args)

   {

      new IceCream();

   } //End Main

} //End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote