Results 1 to 4 of 4
  1. #1
    Shin is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Please help me with my assignment

    hi im new at java. my professor told us to make an ordering system, so i got myself stuck when im now on the transaction code, here's my code,

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    public class Cofee extends JFrame implements ActionListener, ItemListener {
       double x,y,totalamount;
    
        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        JPanel p3 = new JPanel();
    
    
        JLabel lblCoffee = new JLabel("COFFEE");
        JLabel lblPastry = new JLabel("PASTRY");
    
        JLabel lblcof = new JLabel("Total:      P");
        JLabel lblpas = new JLabel("Total:      P");
    
        JTextField txttall = new JTextField(3);
        JTextField txtventi = new JTextField(3);
        JTextField txtgrande = new JTextField(3);
    
        JCheckBox chk1 = new JCheckBox("Tall");
        JCheckBox chk2 = new JCheckBox("Venti");
        JCheckBox chk3 = new JCheckBox("Grande");
    
        JTextField txtcake = new JTextField(3);
        JTextField txtbread = new JTextField(3);
        JTextField txtpie = new JTextField(3);
    
        JCheckBox chk4 = new JCheckBox("Cake");
        JCheckBox chk5 = new JCheckBox("Bread");
        JCheckBox chk6 = new JCheckBox("Pie");
    
        JLabel total = new JLabel("TOTAL AMOUNT           P ");
        JLabel recieve = new JLabel("AMOUNT RECIEVED     P ");
        JLabel change = new JLabel("CHANGE                         P ");
    
        JTextField txtamount = new JTextField(10);
        JTextField txtar = new JTextField(10);
        JTextField txtch = new JTextField(10);
    
        JButton btnCompute = new JButton("COMPUTE");
        JButton btnPurchase = new JButton("PURCHASE");
        JButton btnClose = new JButton("CLOSE");
    
        JLabel pa1 = new JLabel(" ");
        JLabel pa2 = new JLabel(" ");
        int numcf1;
        int numcf2;
        int numcf3;
    
        int numpt1;
        int numpt2;
        int numpt3;
    
        int optchoice;
        final int tall = 170;
        final int venti = 180;
        final int grande = 200;
        final int cake = 100;
        final int bread = 120;
        final int pie = 140;
    
        double talltotal = numcf1 * tall;
        double ventitotal = numcf2 * venti;
        double grandetotal = numcf3 * grande;
    
        double caketotal = numpt1 * cake;
        double breadtotal = numpt2 * bread;
        double pietotal = numpt3 * pie;
        String s1 = String.valueOf(talltotal);
    
    
    
        public Cofee() {
    
            super("Coffee Ordering System");
    
            FlowLayout flow = new FlowLayout();
            setLayout(new FlowLayout(FlowLayout.LEFT, 15, 15));
            setSize(350,380);
            
            add(p1);
            add(p2);
            add(p3);
            p1.setBackground(Color.CYAN);
            p1.setBorder(BorderFactory.createTitledBorder("COFFEE"));
            p1.setLayout(new GridLayout(5,3,1,1));
    
            
            p1.add(chk1);
            p1.add(txttall);
            p1.add(chk2);
            p1.add(txtventi);
            p1.add(chk3);
            p1.add(txtgrande);
            p1.add(lblcof);
            p1.add(pa1);
            
            p2.setBackground(Color.CYAN);
            p2.setBorder(BorderFactory.createTitledBorder("PASTRY"));
            p2.setLayout(new GridLayout(5,3,1,1));
          
            p2.add(chk4);
            p2.add(txtcake);
            p2.add(chk5);
            p2.add(txtbread);
            p2.add(chk6);
            p2.add(txtpie);
            p2.add(lblpas);
            p2.add(pa2);
    
          add(total);
          add(txtamount);
          add(recieve);
          add(txtar);
          add(change);
          add(txtch);
          add(btnCompute);
          add(btnPurchase);
          add(btnClose);
            chk1.setSelected(false);
            chk2.setSelected(false);
            chk3.setSelected(false);
            chk4.setSelected(false);
            chk5.setSelected(false);
            chk6.setSelected(false);
           
          chk1.addActionListener(this);
            chk2.addActionListener(this);
            chk3.addActionListener(this);
            chk4.addActionListener(this);
            chk5.addActionListener(this);
            chk6.addActionListener(this);
            btnCompute.addActionListener(this);
            btnPurchase.addActionListener(this);
            btnClose.addActionListener(this);
    
        }
        public void actionPerformed(ActionEvent e)
        {
    
    
    
           
            
    
    
    
        }
        public void itemStateChanged(ItemEvent e) {
    
            Object source = e.getItemSelectable();
    
            
            if (source == chk1) {
                pa1.setText(s1);
    
    
        }
    
    
        public static void main(String[] args) {
            Cofee display = new Cofee();
            display.setVisible(true);
            display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
    
        }
    }
    Last edited by Shin; 10-15-2012 at 07:50 AM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please help me with my assignment

    Quote Originally Posted by Shin View Post
    so i got myself stuck when im now on the transaction code
    Well that's too bad. Feel free to come back when you have a question.

  3. #3
    Shin is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Please help me with my assignment

    Quote Originally Posted by Junky View Post
    Well that's too bad. Feel free to come back when you have a question.
    my question is when i click the check box. nothing happened,

  4. #4
    Keith Jackson is offline Member
    Join Date
    Sep 2012
    Location
    Maryland, USA
    Posts
    14
    Rep Power
    0

    Default Re: Please help me with my assignment

    Without digging too deep into it, the first thing that jumps out at me is that your actionPerformed method does not contain any code.

Similar Threads

  1. Need help with assignment.
    By smileybear33 in forum New To Java
    Replies: 2
    Last Post: 04-26-2011, 04:47 AM
  2. Need help with a assignment
    By helpMe.Java in forum New To Java
    Replies: 7
    Last Post: 06-06-2010, 05:49 PM
  3. Assignment
    By shinkymar in forum New To Java
    Replies: 2
    Last Post: 03-06-2010, 02:17 PM
  4. need help! assignment due by tmr!
    By keycoffee in forum New To Java
    Replies: 3
    Last Post: 02-10-2010, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •