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

I need help with fixing the bellow errors thanks in advance. (1) private final i

ID: 668390 • Letter: I

Question

I need help with fixing the bellow errors thanks in advance.

(1)    private final int MEALS 1= 200;

private JButton jbtnReset 1= new JButton("RESET ");

typo: no blank space in variable name - MEALS1 and jbtnReset1 are correct.

(2) groupLocations.add(jrbtnPark1);

groupLocations is not declared. Maybe groupLocations1?

Same for groupBedrooms, groupMeals, jpnlLocations, jpnlBedrooms, jpnlMeals, jpnlButton, panel, erc.

(3)     jbtnReset.addActionListener(this);

jbtnReset is not declared. It appears to be the same problem.

Fix all the variable name errors and resubmit ASAP.

import javax.swing.*;

import java.awt.event.*;

public class JVacationRental extends JFrame implements ActionListener

{

//variable declaration

private final int PARK_SIDE1= 600;

private final int POOL_SIDE1 = 750;

private final int LAKE_SIDE1 = 825;

private final int>

private final int TWO_BEDROOMS1 = 150;

private final int THREE_BEDROOMS1 = 225;

private final int MEALS 1= 200;

//setting labels

private JLabel jlblLocations1 = new JLabel("LOCATION: ");

private JLabel jlblBedrooms1 = new JLabel("BEDROOMS: ");

private JLabel jlblMeals1 = new JLabel("INCLUDE MEALS: ");

//setting button variables and designing buttons

private JRadioButton jrbtnPark1 = new JRadioButton("PARK SIDE");

private JRadioButton jrbtnPool1= new JRadioButton("POOL SIDE");

private JRadioButton jrbtnLake1= new JRadioButton("LAKE SIDE");

private JRadioButton jrbtnOne1 = new JRadioButton("1");

private JRadioButton jrbtnTwo1 = new JRadioButton("2");

private JRadioButton jrbtnThree1 = new JRadioButton("3");

private JRadioButton jrbtnYes1 = new JRadioButton("YES");

private JRadioButton jrbtnNo1 = new JRadioButton("NO");

//location bedroom and meals button

private ButtonGroup groupLocations1 = new ButtonGroup();

private ButtonGroup groupBedrooms1 = new ButtonGroup();

private ButtonGroup groupMeals1 = new ButtonGroup();

//button to calculate and result

private JButton jbtnCalculate1 = new JButton(" CALCULATE TOTAL RENT");

private JButton jbtnReset 1= new JButton("RESET ");

//button for total rent

private JLabel result1 = new JLabel("TOTAL RENT: $ 0.0");

//panel setting with the corresponding variables

private JPanel jpnlLocations1 = new JPanel();

private JPanel jpnlBedrooms1 = new JPanel();

private JPanel jpnlMeals1 = new JPanel();

private JPanel jpnlButton1 = new JPanel();

private JPanel jpnlLabel1 = new JPanel();

private JPanel pane1l = new JPanel();

//initializing the cost

private int locationRent1 = 0;

private int bedroomsRent1 = 0;

private int mealsCost1 = 0;

//constructor

public JVacationRental()

{

super("LAMBERT’S VACATION RENTALS ");

//adding frames for the variables

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

groupLocations.add(jrbtnPark1);

groupLocations.add(jrbtnPool1);

groupLocations.add(jrbtnLake1);

groupBedrooms.add(jrbtnOne1);

groupBedrooms.add(jrbtnTwo1);

groupBedrooms.add(jrbtnThree1);

groupMeals.add(jrbtnYes1);

groupMeals.add(jrbtnNo1);

jpnlLocations.add(jlblLocations1);

jpnlLocations.add(jrbtnPark1);

jpnlLocations.add(jrbtnPool1);

jpnlLocations.add(jrbtnLake1);

jpnlBedrooms.add(jlblBedrooms1);

jpnlBedrooms.add(jrbtnOne1);

jpnlBedrooms.add(jrbtnTwo1);

jpnlBedrooms.add(jrbtnThree1);

jpnlMeals.add(jlblMeals1);

jpnlMeals.add(jrbtnYes1);

jpnlMeals.add(jrbtnNo1);

jpnlButton.add(jbtnCalculate1);

jpnlButton.add(jbtnReset1);

jpnlLabel.add(result1);

panel.add(jpnlLocations1);

panel.add(jpnlBedrooms1);

panel.add(jpnlMeals1);

panel.add(jpnlButton1);

panel.add(jpnlLabel1);

//adding panel   

add(panel1);

jrbtnPark1.addItemListener(new LocationsListener());

jrbtnPool1.addItemListener(new LocationsListener());

jrbtnLake1.addItemListener(new LocationsListener());

jrbtnOne1.addItemListener(new BedroomsListener());

jrbtnTwo1.addItemListener(new BedroomsListener());

jrbtnThree1.addItemListener(new

BedroomsListener());

jrbtnYes1.addItemListener(new MealsListener());

jrbtnNo1.addItemListener(new MealsListener());

jbtnCalculate1.addActionListener(this);

jbtnReset.addActionListener(this);

}

//setting action which has to be performed

public void actionPerformed(ActionEvent e)

{

Object source = e.getSource();

if(source == jbtnCalculate)

{

//calculating the rental value.

double totalRent1 = locationRent1 + bedroomsRent1 + mealsCost1;

//displaying rental amount

result1.setText("TOTAL

RENT: $ " + totalRent1);   

}

else if(source == jbtnReset1)

{

groupLocations.clearSelection();

groupBedrooms.clearSelection();

groupMeals.clearSelection();

result.setText("Total Rent: $ 0.0");

//setting initial value =0

locationRent1 = 0;

bedroomsRent1 = 0;

mealsCost1 = 0;

}   

}

private class LocationsListener implements ItemListener

{

public void itemStateChanged(ItemEvent e)

{

Object source = e.getItem();

if(source == jrbtnPark1)

locationRent = PARK_SIDE1;

else if(source == jrbtnPool1)

locationRent = POOL_SIDE1;

else if(source == jrbtnLake1)

locationRent = LAKE_SIDE1;

else

locationRent1 = 0;

}   

}

private class BedroomsListener implements ItemListener

{

public void itemStateChanged(ItemEvent e)

{

Object source = e.getItem();

if(source == jrbtnOne1)

bedroomsRent1 = ONE_BEDROOM1;

else if(source == jrbtnTwo1)

bedroomsRent1 = TWO_BEDROOMS1;

else if(source == jrbtnThree1)

bedroomsRent1 = THREE_BEDROOMS1;

else

bedroomsRent1 = 0;

}   

}

private class MealsListener implements ItemListener

{

public void itemStateChanged(ItemEvent e)

{

Object source = e.getItem();

if(source == jrbtnYes1)

mealsCost1 = MEALS1;

else if(source == jrbtnNo1)

mealsCost1 = 0;

else

mealsCost 1= 0;

}   

}

//main method

public static void main(String[] args)

{   

JVacationRental frame = new JVacationRental();

frame.setSize(350, 250);

frame.setVisible(true);

}

}

Explanation / Answer

import javax.swing.*;

import java.awt.event.*;

public class JVacationRental extends JFrame implements ActionListener

{

//variable declaration

   private final int PARK_SIDE1= 600;

   private final int POOL_SIDE1 = 750;

   private final int LAKE_SIDE1 = 825;

   private final int>

   private final int TWO_BEDROOMS1 = 150;

   private final int THREE_BEDROOMS1 = 225;

   private final int MEALS_1= 200;

//setting labels

   private JLabel jlblLocations1 = new JLabel("LOCATION: ");

   private JLabel jlblBedrooms1 = new JLabel("BEDROOMS: ");

   private JLabel jlblMeals1 = new JLabel("INCLUDE MEALS: ");

//setting button variables and designing buttons

   private JRadioButton jrbtnPark1 = new JRadioButton("PARK SIDE");

   private JRadioButton jrbtnPool1= new JRadioButton("POOL SIDE");

   private JRadioButton jrbtnLake1= new JRadioButton("LAKE SIDE");

   private JRadioButton jrbtnOne1 = new JRadioButton("1");

   private JRadioButton jrbtnTwo1 = new JRadioButton("2");

   private JRadioButton jrbtnThree1 = new JRadioButton("3");

   private JRadioButton jrbtnYes1 = new JRadioButton("YES");

   private JRadioButton jrbtnNo1 = new JRadioButton("NO");

//location bedroom and meals button

   private ButtonGroup groupLocations1 = new ButtonGroup();

   private ButtonGroup groupBedrooms1 = new ButtonGroup();

   private ButtonGroup groupMeals1 = new ButtonGroup();

//button to calculate and result

   private JButton jbtnCalculate1 = new JButton(" CALCULATE TOTAL RENT");

   private JButton jbtnReset1= new JButton("RESET ");

//button for total rent

   private JLabel result1 = new JLabel("TOTAL RENT: $ 0.0");

//panel setting with the corresponding variables

   private JPanel jpnlLocations1 = new JPanel();

   private JPanel jpnlBedrooms1 = new JPanel();

   private JPanel jpnlMeals1 = new JPanel();

   private JPanel jpnlButton1 = new JPanel();

   private JPanel jpnlLabel1 = new JPanel();

   private JPanel pane1l = new JPanel();

    //initializing the cost

   private int locationRent1 = 0;

   private int bedroomsRent1 = 0;

   private int mealsCost1 = 0;

//constructor

   public JVacationRental()

   {

          super("LAMBERT’S VACATION RENTALS ");

          //adding frames for the variables

          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

          groupLocations.add(jrbtnPark1);

          groupLocations.add(jrbtnPool1);

          groupLocations.add(jrbtnLake1);

   

          groupBedrooms.add(jrbtnOne1);

          groupBedrooms.add(jrbtnTwo1);

         groupBedrooms.add(jrbtnThree1);

   

          groupMeals.add(jrbtnYes1);

          groupMeals.add(jrbtnNo1);

   

          jpnlLocations.add(jlblLocations1);

          jpnlLocations.add(jrbtnPark1);

          jpnlLocations.add(jrbtnPool1);

          jpnlLocations.add(jrbtnLake1);

   

          jpnlBedrooms.add(jlblBedrooms1);

          jpnlBedrooms.add(jrbtnOne1);

          jpnlBedrooms.add(jrbtnTwo1);

          jpnlBedrooms.add(jrbtnThree1);

   

          jpnlMeals.add(jlblMeals1);

          jpnlMeals.add(jrbtnYes1);

          jpnlMeals.add(jrbtnNo1);

   

          jpnlButton.add(jbtnCalculate1);

          jpnlButton.add(jbtnReset1);

          jpnlLabel.add(result1);

   

          panel.add(jpnlLocations1);

          panel.add(jpnlBedrooms1);

          panel.add(jpnlMeals1);

          panel.add(jpnlButton1);

          panel.add(jpnlLabel1);

        //adding panel           

          add(panel1);

   

jrbtnPark1.addItemListener(new LocationsListener());

jrbtnPool1.addItemListener(new LocationsListener());

jrbtnLake1.addItemListener(new LocationsListener());

            jrbtnOne1.addItemListener(new BedroomsListener());

            jrbtnTwo1.addItemListener(new BedroomsListener());

jrbtnThree1.addItemListener(new

            BedroomsListener());

            jrbtnYes1.addItemListener(new MealsListener());

            jrbtnNo1.addItemListener(new MealsListener());

            jbtnCalculate1.addActionListener(this);

            jbtnReset.addActionListener(this);

}

//setting action which has to be performed

   public void actionPerformed(ActionEvent e)

   {

Object source = e.getSource();

   if(source == jbtnCalculate)

              {

//calculating the rental value.

double totalRent1 = locationRent1 + bedroomsRent1 + mealsCost1;

                        //displaying rental amount

         result1.setText("TOTALRENT: $ " + totalRent1);       

              }

          else if(source == jbtnReset1)

          {

                   groupLocations.clearSelection();

                   groupBedrooms.clearSelection();

                   groupMeals.clearSelection();

                   result.setText("Total Rent: $ 0.0");

                   //setting initial value =0

                   locationRent1 = 0;

                   bedroomsRent1 = 0;

                   mealsCost1 = 0;

          }   

   }

   private class LocationsListener implements ItemListener

   {

       public void itemStateChanged(ItemEvent e)

       {

           Object source = e.getItem();

     if(source == jrbtnPark1)

                   locationRent = PARK_SIDE1;

           else if(source == jrbtnPool1)

                   locationRent = POOL_SIDE1;

           else if(source == jrbtnLake1)

                     locationRent = LAKE_SIDE1;

           else

                   locationRent1 = 0;

       }   

   }

   private class BedroomsListener implements ItemListener

   {

       public void itemStateChanged(ItemEvent e)

       {

           Object source = e.getItem();

     if(source == jrbtnOne1)

                     bedroomsRent1 = ONE_BEDROOM1;

           else if(source == jrbtnTwo1)

                   bedroomsRent1 = TWO_BEDROOMS1;

           else if(source == jrbtnThree1)

                   bedroomsRent1 = THREE_BEDROOMS1;

           else

                   bedroomsRent1 = 0;

       }   

   }

   private class MealsListener implements ItemListener

   {

       public void itemStateChanged(ItemEvent e)

       {

           Object source = e.getItem();

   if(source == jrbtnYes1)

                     mealsCost1 = MEALS1;

           else if(source == jrbtnNo1)

                     mealsCost1 = 0;

           else

                     mealsCost1= 0;

       }   

   }

//main method

   public static void main(String[] args)

   {   

          JVacationRental frame = new JVacationRental();

          frame.setSize(350, 250);

          frame.setVisible(true);

   }

}

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