Please, i need help. I am Java stupid and have to take the class for an electronics program. I have it written out and now i really need the items to add up when you input a quantity and hit the check out. Please help. Tell me where to input it and how to write the expression.
Here is my code.
package lab3; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * * @author NICK WALKER */ public class GuiFrame extends JFrame implements ActionListener { Container Cart = getContentPane(); GridLayout Grid = new GridLayout(7,2); JCheckBox Buck = new JCheckBox("Buck $0.50"); JTextField BuckT = new JTextField(); JCheckBox A = new JCheckBox("A $1.00"); JTextField AT = new JTextField(); JCheckBox Roo = new JCheckBox("Roo $2.00"); JTextField RooT = new JTextField(); JCheckBox Bon = new JCheckBox("Bon $5.00"); JTextField BonT = new JTextField(); JCheckBox Zai = new JCheckBox("Zai $10.00"); JTextField ZaiT = new JTextField(); JButton checkout = new JButton("Checkout"); JButton blank = new JButton(); JLabel ordertotal = new JLabel("Order Total $"); JTextField $due = new JTextField(); int total = 0; double Bucks = .50; double As = 1.00; double Roos = 2.00; double Bons = 5.00; double Zais = 10.00; public GuiFrame(){ this.setTitle("We Love Just One Movie.com shopping cart"); this.setSize(400,350); this.setLocationRelativeTo(null); BuckT.setEditable(false); AT.setEditable(false); RooT.setEditable(false); BonT.setEditable(false); ZaiT.setEditable(false); blank.setEnabled(false); $due.setVisible(false); Cart.setLayout(Grid); addComponents(); registerEventGenerators(); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource()==Buck){ BuckT.setEditable(true); } if (e.getSource()==A){ AT.setEditable(true); } if (e.getSource()==Roo){ RooT.setEditable(true); } if (e.getSource()==Bon){ BonT.setEditable(true); } if (e.getSource()==Zai){ ZaiT.setEditable(true); } if (e.getSource()==checkout){ $due.setVisible(true); } } private void addComponents() { Cart.add(Buck); Cart.add(BuckT); Cart.add(A); Cart.add(AT); Cart.add(Roo); Cart.add(RooT); Cart.add(Bon); Cart.add(BonT); Cart.add(Zai); Cart.add(ZaiT); Cart.add(checkout); Cart.add(blank); Cart.add(ordertotal); Cart.add($due); } private void registerEventGenerators() { checkout.addActionListener(this); Buck.addActionListener(this); BuckT.addActionListener(this); A.addActionListener(this); AT.addActionListener(this); Roo.addActionListener(this); Roo.addActionListener(this); Bon.addActionListener(this); BonT.addActionListener(this); Zai.addActionListener(this); ZaiT.addActionListener(this); } }