Write an application for a construction company to handle a costumer\'s order to
ID: 3661327 • Letter: W
Question
Write an application for a construction company to handle a costumer's order to build a new home. Use separate ButtonGroups to allow the customer to select one of four modells, the number of bedrooms, and a garage type. Assume that the modells are the Aspen, $10,000; the Bryttany, $120,000; the Colonial $180,000; or the Dartmoor, $250,000; Assume that any model can have two, three or four bedrooms and that each bedroom adds $10500 to the base price. Assume that the garage type can be zero-, one-,two-, or three car, and that each car adds $7,775 to the price. Save the file as JMyNewHome.java. Exercise 4. Thanks GeorgeExplanation / Answer
am unsure how to code it. Any help you can give me is appreciated. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class NewHome extends JFrame implements ItemListener { int newHome1 = 100000; int newHome2 = 120000; int newHome3 = 180000; int newHome4 = 250000; JCheckBox homeBox1 = new JCheckBox("Aspen $" + newHome1,true); JCheckBox homeBox2 = new JCheckBox("Brittany $" + newHome2,false); JCheckBox homeBox3 = new JCheckBox("Colonial $" + newHome3,false); JCheckBox homeBox4 = new JCheckBox("Dartmoor $" + newHome4,false); JLabel homeBuildersLabel = new JLabel("Home Builders Inc."); JLabel homeOptionLabel = new JLabel("Select the desired model"); JLabel homeOptionLabel0 = new JLabel(""); JLabel ePrice = new JLabel("The price of your home is:"); JTextField totPrice = new JTextField(10); public NewHome() { super("Home Price Calculator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pane = new JPanel(); pane.add(homeBuildersLabel); pane.add(homeOptionLabel); pane.add(homeOptionLabel0); pane.add(homeBox1); pane.add(homeBox2); pane.add(homeBox3); pane.add(homeBox4); ButtonGroup homeGroup = new ButtonGroup(); homeGroup.add(homeBox1); homeGroup.add(homeBox2); homeGroup.add(homeBox3); homeGroup.add(homeBox4); pane.add(ePrice); pane.add(totPrice); totPrice.setText("$" + newHome1); homeBox1.addItemListener(this); homeBox2.addItemListener(this); homeBox3.addItemListener(this); homeBox4.addItemListener(this); setContentPane(pane); } public static void main(String[] arguments) { JFrame aFrame = new NewHome(); aFrame.setSize(250,500); aFrame.setVisible(true); } public void itemStateChanged(ItemEvent event) { if(homeBox1.isSelected()) totPrice.setText("$" + newHome1); else if(homeBox2.isSelected()) totPrice.setText("$" + newHome2); else if(homeBox3.isSelected()) totPrice.setText("$" + newHome3); else // if(homeBox4.isSelected()) totPrice.setText("$" + newHome4); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.