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

(1) private final int MEALS 1= 200; private JButton jbtnReset 1= new JButton(\"R

ID: 668802 • Letter: #

Question

(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.

declare a variable with "-1" and use it without "1". To avoid any confusion, do NOT use "1" at the end of variable name.

i need help doing thiis in the below code

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);

}

}

Explanation / Answer

import javax.swing.*;
import java.awt.event.*;
public class JVacationRental extends JFrame implements ActionListener
{
//variable declaration
private final int PARK_SID-1E= 600;
private final int POOL_SID-1E = 750;
private final int LAKE_SID-1E = 825;
private final int ONE_BEDROO-1M= 75;
private final int TWO_BEDROOM-1S = 150;
private final int THREE_BEDROOM-1S = 225;
private final int MEAL-1S= 200;
//setting labels
private JLabel jlblLocation-1s = new JLabel("LOCATION: ");
private JLabel jlblBedroom-1s = new JLabel("BEDROOMS: ");
private JLabel jlblMeal-1s = new JLabel("INCLUDE MEALS: ");
//setting button variables and designing buttons
private JRadioButton jrbtnPar-1k = new JRadioButton("PARK SIDE");
private JRadioButton jrbtnPoo-1l= new JRadioButton("POOL SIDE");
private JRadioButton jrbtnLak-1e= new JRadioButton("LAKE SIDE");
private JRadioButton jrbtnOn-1e = new JRadioButton("1");
private JRadioButton jrbtnTw-1o = new JRadioButton("2");
private JRadioButton jrbtnThre-1e = new JRadioButton("3");
private JRadioButton jrbtnYe-1s = new JRadioButton("YES");
private JRadioButton jrbtnN-1o = new JRadioButton("NO");
//location bedroom and meals button
private ButtonGroup groupLocation-1s = new ButtonGroup();
private ButtonGroup groupBedroom-1s = new ButtonGroup();
private ButtonGroup groupMeal-1s = new ButtonGroup();
//button to calculate and result
private JButton jbtnCalculat-1e = new JButton(" CALCULATE TOTAL RENT");
private JButton jbtnRese-1t= new JButton("RESET ");
//button for total rent
private JLabel resul-1t = new JLabel("TOTAL RENT: $ 0.0");
//panel setting with the corresponding variables
private JPanel jpnlLocation-1s = new JPanel();
private JPanel jpnlBedroom-1s = new JPanel();
private JPanel jpnlMeal-1s = new JPanel();
private JPanel jpnlButto-1n = new JPanel();
private JPanel jpnlLabe-1l = new JPanel();
private JPanel pan-1e = new JPanel();
//initializing the cost
private int locationRen-1t = 0;
private int bedroomsRen-1t = 0;
private int mealsCos-1t = 0;
//constructor
public JVacationRental()
{
super("LAMBERT’S VACATION RENTALS ");
//adding frames for the variables
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
groupLocations.add(jrbtnPar-1k);
groupLocations.add(jrbtnPoo-1l);
groupLocations.add(jrbtnLak-1e);

groupBedrooms.add(jrbtnOn-1e);
groupBedrooms.add(jrbtnTw-1o);
groupBedrooms.add(jrbtnThre-1e);

groupMeals.add(jrbtnYe-1s);
groupMeals.add(jrbtnN-1o);

jpnlLocations.add(jlblLocation-1s);
jpnlLocations.add(jrbtnPar-1k);
jpnlLocations.add(jrbtnPoo-1l);
jpnlLocations.add(jrbtnLak-1e);

jpnlBedrooms.add(jlblBedroom-1s);
jpnlBedrooms.add(jrbtnOn-1e);
jpnlBedrooms.add(jrbtnTw-1o);
jpnlBedrooms.add(jrbtnThre-1e);

jpnlMeals.add(jlblMeal-1s);
jpnlMeals.add(jrbtnYe-1s);
jpnlMeals.add(jrbtnN-1o);

jpnlButton.add(jbtnCalculat-1e);
jpnlButton.add(jbtnRese-1t);
jpnlLabel.add(resul-1t);

panel.add(jpnlLocation-1s);
panel.add(jpnlBedroom-1s);
panel.add(jpnlMeal-1s);
panel.add(jpnlButto-1n);
panel.add(jpnlLabe-1l);
//adding panel   
add(pane-1l);

jrbtnPar-1k.addItemListener(new LocationsListener());
jrbtnPoo-1l.addItemListener(new LocationsListener());
jrbtnLak-1e.addItemListener(new LocationsListener());
jrbtnOn-1e.addItemListener(new BedroomsListener());
jrbtnTw-1o.addItemListener(new BedroomsListener());
jrbtnThre-1e.addItemListener(new
BedroomsListener());
jrbtnYe-1s.addItemListener(new MealsListener());
jrbtnN-1o.addItemListener(new MealsListener());
jbtnCalculat-1e.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 totalRen-1t = locationRen-1t + bedroomsRen-1t + mealsCos-1t;
//displaying rental amount
resul-1t.setText("TOTALRENT: $ " + totalRen-1t);   
}
else if(source == jbtnRese-1t)
{
groupLocations.clearSelection();
groupBedrooms.clearSelection();
groupMeals.clearSelection();
result.setText("Total Rent: $ 0.0");
//setting initial value =0
locationRen-1t = 0;
bedroomsRen-1t = 0;
mealsCos-1t = 0;
}   
}
private class LocationsListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
Object source = e.getItem();
if(source == jrbtnPar-1k)
locationRent = PARK_SID-1E;
else if(source == jrbtnPoo-1l)
locationRent = POOL_SID-1E;
else if(source == jrbtnLak-1e)
locationRent = LAKE_SID-1E;
else
locationRen-1t = 0;
}   
}
private class BedroomsListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
Object source = e.getItem();
if(source == jrbtnOn-1e)
bedroomsRen-1t = ONE_BEDROO-1M;
else if(source == jrbtnTw-1o)
bedroomsRen-1t = TWO_BEDROOM-1S;
else if(source == jrbtnThre-1e)
bedroomsRen-1t = THREE_BEDROOM-1S;
else
bedroomsRen-1t = 0;
}   
}
private class MealsListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
Object source = e.getItem();
if(source == jrbtnYe-1s)
mealsCos-1t = MEAL-1S;
else if(source == jrbtnN-1o)
mealsCos-1t = 0;
else
mealsCos-1t= 0;
}   
}
//main method
public static void main(String[] args)
{   
JVacationRental frame = new JVacationRental();
frame.setSize(350, 250);
frame.setVisible(true);
}
}