import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.BorderFactory;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
public class CurrencyConverter extends Applet implements ActionListener
{
JLabel header;
JLabel amountlabel;
JLabel fromlabel;
JLabel exchangeratelabel;
JLabel calcamtlabel;
JTextField amountfield;
JTextField exchangeratefield;
JTextField calcamtfield;
Choice fromchoice;
double[] value={1.00000,43.5241,101.830,4.85908,10.1931,2980.70,29.8823,1.45021,1.45006,5.48783,0.43355,17.9677,5.52844,11.3770,4.40437,4.85908,1.44881,252.415,201.184,117.540,0.58340,1,434.32,0.52105,2.55983,29.8823,45.3683,0.31801,11.7450,5.85440,2.91617,148.510,31,434.3,29.2834,76.4078,22.3162,177.516,123.253,6.49595,0.97210,1.59249,7.85630,0.62392,76.4078};
JButton calculate;
public void init()
{
setBackground(Color.green);
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints a = new GridBagConstraints();
JLabel header = new JLabel("Currency Conversion Calculator");
a.gridx = 0;
a.gridy = 0;
a.insets = new Insets(10,10,10,10);
header.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel.add(header,a);
add(panel, BorderLayout.NORTH);
JPanel panel1 = new JPanel(new GridBagLayout());
GridBagConstraints b = new GridBagConstraints();
JLabel amountlabel = new JLabel("Amount of Dollars to be Exchange");
b.gridx = 1;
b.gridy = 1;
b.insets = new Insets(10,10,10,10);
amountlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel1.add(amountlabel,b);
JLabel fromlabel = new JLabel("Convert From:");
b.gridx = 1;
b.gridy = 2;
b.insets = new Insets(10,10,10,10);
fromlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel1.add(fromlabel,b);
add(panel1, BorderLayout.WEST);
JPanel panel4 = new JPanel(new GridBagLayout());
GridBagConstraints f = new GridBagConstraints();
JTextField amountfield = new JTextField(15);
f.gridx = 2;
f.gridy = 1;
f.insets = new Insets(10,10,10,10);
amountfield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel4.add(amountfield,f);
fromchoice = new Choice();
f.gridx = 2;
f.gridy = 2;
f.insets = new Insets(10,10,10,10);
fromlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel4.add(fromchoice,f);
fromchoice.addItem("United States US Dollar (USD)");
fromchoice.addItem("Philippines Philippine Peso (PHP)");
fromchoice.addItem("Albania Albanian Lek (ALL)");
fromchoice.addItem("Andorra Andorran Franc (ADF)");
fromchoice.addItem("Austria Austrian Schilling (ATS)");
fromchoice.addItem("Belarus Belarusian Ruble (BYR)");
fromchoice.addItem("Belgium Belgian Franc (BEF)");
fromchoice.addItem("Bosnia Bosnia Mark (BAM)");
fromchoice.addItem("Bulagria Bulgarian Lev (BGN)");
fromchoice.addItem("Cyprus Cypriot Pound (CYP)");
fromchoice.addItem("Czech Republic Czech Koruna (CZK)");
fromchoice.addItem("Denmark Danish Krone (DKK)");
fromchoice.addItem("Estonia Estonian Kroon (EEK)");
fromchoice.addItem("Findland Finnish Markka (FIM)");
fromchoice.addItem("Germany German Mark (DEM)");
fromchoice.addItem("Greece Greek Drachma (GRD)");
fromchoice.addItem("Hungary Hungarian Forint (HUF)");
fromchoice.addItem("Iceland Iceland Krona (ISK)");
fromchoice.addItem("Ireland Irish Punt (IEP)");
fromchoice.addItem("Italy Italian Lira (ITL)");
fromchoice.addItem("Latvia Latvian Lats (LVL)");
fromchoice.addItem("Lithuania Lithuanian Litas (LTL)");
fromchoice.addItem("Luxemburg Luxembourg Franc (LUF)");
fromchoice.addItem("Macedonia Macedonian Denar (MKD)");
fromchoice.addItem("Malta Maltese Lira (MTL)");
fromchoice.addItem("Moldova Moldovan Leu (MDL)");
fromchoice.addItem("Norway Norwegian Kroner (NOK)");
fromchoice.addItem("Poland Polish Zloty (PLN)");
fromchoice.addItem("Portugal Portuguese Escudo (PTE)");
fromchoice.addItem("Romania Romanian Lei (ROL)");
fromchoice.addItem("Russia Russian Rouble (RUB)");
fromchoice.addItem("Serbia Serbian Dinar (RSD)");
fromchoice.addItem("Slovakia Slovak Koruna (SKK)");
fromchoice.addItem("Slovenia Slovenian Tolar (SIT)");
fromchoice.addItem("Spain Spanish Peseta (ESP)");
fromchoice.addItem("Sweden Swedish Krona (SEK)");
fromchoice.addItem("Switzerland Swiss Franc (CHF)");
fromchoice.addItem("Turkey Turkish Lira (TRY)");
fromchoice.addItem("Ukraine Ukraine Hryvnia (UAH)");
fromchoice.addItem("United Kingdom British Pound (GBP)");
fromchoice.addItem("Yugoslavia Yugoslav Dinar (YUN)");
add(panel4, BorderLayout.NORTH);
JPanel panel3 = new JPanel(new GridBagLayout());
GridBagConstraints d = new GridBagConstraints();
JLabel exchangeratelabel = new JLabel("Exchange Rate");
d.gridx = 1;
d.gridy = 4;
d.insets = new Insets(10,10,10,10);
exchangeratelabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel3.add(exchangeratelabel,d);
JLabel calcamtlabel = new JLabel("Calculated Amount");
d.gridx = 1;
d.gridy = 5;
d.insets = new Insets(10,10,10,10);
calcamtlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel3.add(calcamtlabel,d);
add(panel3, BorderLayout.EAST);
JPanel panel5 = new JPanel(new GridBagLayout());
GridBagConstraints e = new GridBagConstraints();
JTextField calcamtfield = new JTextField(15);
e.gridx = 2;
e.gridy = 5;
e.insets = new Insets(10,10,10,10);
calcamtfield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel5.add(calcamtfield,e);
JTextField exchangeratefield = new JTextField(15);
e.gridx = 2;
e.gridy = 4;
e.insets = new Insets(10,10,10,10);
exchangeratefield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
panel5.add(exchangeratefield,e);
add(panel5, BorderLayout.WEST);
JButton calculate = new JButton("Calculate");
c.gridx = 1;
c.gridy = 3;
c.insets = new Insets(10,10,10,10);
calculate.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
calculate.addActionListener(this);
add(calculate);
}
calculate.addActionListener(new ActionListener())
{
public void actionPerformed(ActionEvent e)
{
double cal,total;
int actval = fromchoice.getSelectedIndex();
total = value[actval];
int af = Integer.parseInt(amountfield.getText());
cal=af*total;
exchangeratefield.setText(""+total);
calcamtfield.setText(""+cal);
}
});
}