I've an assignment that is coding a "currency converter". I managed to generate the program screen, but I don't know where and how to code in order to make calculations for currency conversion. If you've any solution or idea about it, please leave your comments on that topic page..
Thanks a lot for everything from now on.
Have a nice Sunday!!!!
package assignment;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DecimalFormat;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MoneyConverter extends JFrame {
private JFrame mainFrame;
private JLabel inLabel;
private JTextField inField;
private JLabel tinLabel;
private JTextField tinField;
private JLabel zinLabel;
private JTextField zinField;
private JButton closeButton;
private JButton usdtoaudButton;
private JButton audtousdButton;
public MoneyConverter() {
mainFrame = new JFrame("Money Converter");
inLabel = new JLabel(" AUD ");
inField = new JTextField(20);
tinLabel = new JLabel(" Rate ");
tinField = new JTextField(20);
zinLabel = new JLabel(" USD ");
zinField = new JTextField(20);
usdtoaudButton = new JButton("USD to AUD");
audtousdButton = new JButton("AUD to USD");
closeButton = new JButton("Close");
Container c = mainFrame.getContentPane();
c.setLayout(new FlowLayout());
c.add(inLabel);
c.add(inField);
c.add(tinLabel);
c.add(tinField);
c.add(zinLabel);
c.add(zinField);
c.add(usdtoaudButton);
c.add(audtousdButton);
c.add(closeButton);
mainFrame.setSize(400,180);
mainFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e) {System.exit(0);
}
});
USDtoAUDButtonHandler uhandler = new USDtoAUDButtonHandler();
usdtoaudButton.addActionListener(uhandler);
CloseButtonHandler chandler = new CloseButtonHandler();
closeButton.addActionListener(chandler);
AUDtoUSDButtonHandler ahandler = new AUDtoUSDButtonHandler();
audtousdButton.addActionListener(ahandler);
mainFrame.show();
}
class USDtoAUDButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class AUDtoUSDButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class CloseButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
public static void main(String args [])
{
MoneyConverter app = new MoneyConverter();
}
}
Edited by John, 29 March 2009 - 04:43 PM.
Please use [code] tags when posting code.


Sign In
Create Account

Back to top










