Operation The user configures the components of a computer system by selecting i
ID: 3691653 • Letter: O
Question
Operation
The user configures the components of a computer system by selecting items from the combo boxes, radio buttons, and check boxes.
When the user clicks the Calculate button, the application calculates the price of the system by adding the cost of each selected component to a base price.
When the user closes the frame or presses the Exit button, the application exits.
Add a feature that indicates how changing each selection will affect the price. For example, if Windows 7 Ultimate is currently selected, change the text for the Windows 7 Professional label to “Windows 7 Professional (subtract $100).” However, if the Professional edition is currently selected, the check box for the Ultimate edition should read Windows 7 Ultimate (add $100).”
Print a summary of the configuration to a Dialog Message Box when the user clicks the Calculate button.
Specifications
The base price of the computer is $500.
The user can select one of three processors:
Quad Core 3.40GHz included in base price
Quad Core 3.50GHz add $50.00
Quad Core 3.60GHz add $150
The user can select one of four memory configurations:
4GB included in base price
8GB add $50.00
16GB add $100.00
32GB add $150.00
The user can select one of three disk configurations:
500GB included in base price
1TB add $50.00
2TB add $150.00
The user can select one of two operating systems:
Windows 7 Professional included in base price
Windows 7 Ultimate add $100.00
The user can select any or all of the following three software packages:
Office package add $400.00
Accounting package add $200.00
Graphics package add $600.00
Hints
Consider using a separate class to represent each of the configuration options.
Don’t forget to include the base price ($500) when the program starts.
Create a Java Computer Configuration Calculation program with NetBeans that satisfies the specifications stated above.
Put General Comments at the beginning of the project that includes (1) your name, (2) the project name, (3) the date, and (4) a description of the project.
Turn in a ZIP file of the final version of the program. Include a Word document which contains screen shots of the program. Test a variety of configuration calculations.
Include an interface plan that identifies the text of each control when the program starts and the name of each control. Also include a property plan that identifies the properties set by the developer for each control.
Report an estimate of the time it took to complete the project. Report a single value in hours. Also give a single rating of the project, on an ordinal scale, as either (1) Easy, (2) Moderate, (3) Difficult, OR (4) Challenging.
Explanation / Answer
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comp_system_cal;
/**
*
* @author TANAY
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
jComboBox1 = new javax.swing.JComboBox();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jRadioButton4 = new javax.swing.JRadioButton();
jRadioButton5 = new javax.swing.JRadioButton();
jRadioButton6 = new javax.swing.JRadioButton();
jRadioButton7 = new javax.swing.JRadioButton();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox3 = new javax.swing.JCheckBox();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Quad Core 3.40GHz", "Quad Core 3.50GHz", "Quad Core 3.60GHz", " " }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("4GB");
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("8GB");
buttonGroup1.add(jRadioButton3);
jRadioButton3.setText("16GB");
buttonGroup1.add(jRadioButton4);
jRadioButton4.setText("32GB");
buttonGroup2.add(jRadioButton5);
jRadioButton5.setText("500GB");
buttonGroup2.add(jRadioButton6);
jRadioButton6.setText("1TB");
buttonGroup2.add(jRadioButton7);
jRadioButton7.setText("2TB");
jCheckBox1.setText("jCheckBox1");
jCheckBox2.setText("jCheckBox2");
jCheckBox3.setText("jCheckBox3");
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("jLabel1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(165, 165, 165)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(69, 69, 69)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jRadioButton5)
.addComponent(jRadioButton1)
.addComponent(jCheckBox1))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jRadioButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jRadioButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jRadioButton4))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jCheckBox2)
.addComponent(jRadioButton6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jRadioButton7)
.addComponent(jCheckBox3)))))
.addGroup(layout.createSequentialGroup()
.addGap(152, 152, 152)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
.addComponent(jButton1))))
.addContainerGap(164, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2)
.addComponent(jRadioButton3)
.addComponent(jRadioButton4))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton5)
.addComponent(jRadioButton6)
.addComponent(jRadioButton7))
.addGap(53, 53, 53)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox1)
.addComponent(jCheckBox2)
.addComponent(jCheckBox3))
.addGap(18, 18, 18)
.addComponent(jLabel1)
.addGap(24, 24, 24)
.addComponent(jButton1)
.addContainerGap(137, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int p=0,m=0,d=0,pack=0,pack1=0,pack2=0,tot;
if( jComboBox1.getSelectedItem()=="Quad Core 3.40GHz")
p=0;
if( jComboBox1.getSelectedItem()=="Quad Core 3.50GHz")
p=50;
if( jComboBox1.getSelectedItem()=="Quad Core 3.60GHz")
p=150;
if(jRadioButton1.isSelected())
{
m=0;
}
if(jRadioButton2.isSelected())
{
m=50;
}
if(jRadioButton3.isSelected())
{
m=100;
}
if(jRadioButton4.isSelected())
{
m=150;
}
if(jRadioButton5.isSelected())
{
d=0;
}
if(jRadioButton6.isSelected())
{
d=50;
}
if(jRadioButton7.isSelected())
{
d=150;
}
if(jCheckBox1.isSelected())
{
pack=400;
}
if(jCheckBox2.isSelected())
{
pack1=200;
}
if(jCheckBox3.isSelected())
{
pack2=600;
}
tot=500+p+d+m+pack+pack1+pack2;
jLabel1.setText(String.valueOf(tot));
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton jButton1;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JRadioButton jRadioButton6;
private javax.swing.JRadioButton jRadioButton7;
// End of variables declaration
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.