so i no ive read this stuff about hmwrk. but i have done a lot of work and dont want anyone to finish it for me i just need advice, im making a coffee machine and i have made a layout, but i dont no how to put in the math part, i have the buttons and when clicked it displays but i need to no where i put my math. here is my code:

/**
* MyGUI User Interface Class
*/
//imports for graphics and user interaction
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Color;

/**
* MyGUI class represents a graphical user interface
* @author Your Name
*/
public class MyGUI extends JFrame implements ActionListener {
//instance variables - elements in the GUI
private JButton myButton;
private JButton aButton;
private JButton bButton;
private JButton cButton;
private JButton dButton;
private JButton eButton;
private JButton fButton;
private JButton gButton;
private JButton hButton;
private JRadioButton firstRadio, secondRadio;
public JTextArea text;

/**
* Constructor function creates and displays
* the basic elements in the GUI
*/
public MyGUI()
{
//set the window properties
setTitle("Manraj's Coffee machine");
setSize(500, 500);
setLocation(50, 50);


//create Panels
JPanel northPanel = new JPanel();
JPanel centerPanel = new JPanel();
JPanel southPanel = new JPanel();
JPanel westPanel = new JPanel();
add(northPanel, "North");
add(centerPanel, "Center");
add(southPanel, "South");
add(westPanel, "West");
westPanel.setBackground(Color.black);
centerPanel.setBackground(Color.pink);

southPanel.setBackground(Color.red);
//create widgets
aButton = new JButton("Black Coffee");
aButton.addActionListener(this);
myButton = new JButton("Moka Coffee");
myButton.addActionListener(this);
bButton = new JButton("Expresso");
bButton.addActionListener(this);
cButton = new JButton("2$");
cButton.addActionListener(this);

dButton = new JButton("1$");
dButton.addActionListener(this);
eButton = new JButton("25¢");
eButton.addActionListener(this);
fButton = new JButton("10¢");
fButton.addActionListener(this);
gButton = new JButton("5¢");
gButton.addActionListener(this);
hButton = new JButton("reset");
hButton.addActionListener(this);
firstRadio = new JRadioButton("Sugar");
firstRadio.addActionListener(this);
secondRadio = new JRadioButton("Cream");
secondRadio.addActionListener(this);
text = new JTextArea(" ", 15, 15);
text.setEditable(false);

northPanel.setLayout(new GridLayout(2,3));{

northPanel.add(myButton);
northPanel.add(aButton);
northPanel.add(bButton);
northPanel.add(firstRadio);
northPanel.add(secondRadio);
}

centerPanel.add(text);

westPanel.setLayout(new GridLayout(5, 1));{
westPanel.add(cButton);
westPanel.add(dButton);
westPanel.add(eButton);
westPanel.add(fButton);
westPanel.add(gButton);
}
southPanel.setSize(2,2);
southPanel.add(hButton);


setVisible(true);
}
/**
* actionPerformed will determine how the program
* responds to user interaction
*/
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "Black Coffee"){//if the event matches this one, do what's in the brackets
text.append("Black Coffee costs 2$\n");
}
if (e.getActionCommand() == "Moka Coffee"){//if the event matches this one, do what's in the brackets
text.append("Moka Coffee costs 2$\n");
}
if (e.getActionCommand() == "Expresso"){//if the event matches this one, do what's in the brackets
text.append("Expresso costs 2$\n");
}
if (e.getActionCommand() == "2$"){//if the event matches this one, do what's in the brackets
text.append("you have deposited 2$\n");
}
if (e.getActionCommand() == "1$"){//if the event matches this one, do what's in the brackets
text.append("you have deposited 1$\n");
}
if (e.getActionCommand() == "25¢"){//if the event matches this one, do what's in the brackets
text.append("you have deposited 25¢\n");
}
if (e.getActionCommand() == "10¢"){//if the event matches this one, do what's in the brackets
text.append("you have deposited 10¢\n");
}
if (e.getActionCommand() == "5¢"){//if the event matches this one, do what's in the brackets
text.append("you have depostied 5¢\n");
}
if (e.getActionCommand() == "Sugar"){//if the event matches this one, do what's in the brackets
text.append("you have added sugar\n");
}
if (e.getActionCommand() == "Cream"){//if the event matches this one, do what's in the brackets
text.append("you have added cream\n");
}


}
}


that is all just please give me some pointers. thanks

0x3A28213A
0x6339392C
0x7363682E

just add it in with your event handlers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.