Answer :
Please find the code below:
package graphichal;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class CurrencyConverter{
public static void main(String[] args){ //main class
final JFrame f=new JFrame();
//ADD TEXT FIELDS
final JTextField currencyInput=new JTextField(20);
final JLabel output = new JLabel();
JButton update=new JButton("Convert");
// SET LAYOUT TO GRID
f.setLayout(new GridLayout(4, 3));
//ADD COMBO BOXES
final JComboBox<String> jc=new JComboBox<String>();
jc.addItem("EUR");
jc.addItem("USD");
jc.addItem("GBP");
final JComboBox<String> jc2=new JComboBox<String>();
jc2.addItem("EUR");
jc2.addItem("USD");
jc2.addItem("GBP");
f.add(new JLabel("SELECT FROM CURRENCY"));
f.add(currencyInput);
f.add(new JLabel("SELECT TO CURRENCY"));
f.add(jc);
f.add(new JLabel("ENTER VALUE IN THE TEXT BOX"));
f.add(jc2);
final JLabel error = new JLabel("");
final JLabel error1 = new JLabel("");
error.setForeground(Color.red);
error1.setForeground(Color.red);
f.add(error);
f.add(update);
f.add(error1);
final JLabel resultMsg =new JLabel("");
f.add(resultMsg);
f.add(output);
update.setBounds(150, 300,200, 20);
f.setVisible(true);
f.pack();
update.addActionListener(new ActionListener(){ //listener for button getResult
public void actionPerformed(ActionEvent e){
//DO CALCULATIONS BASED ON INPUT AND OUTPUT
try{
resultMsg.setText("CONVERTED VALUE IS ");
error.setText("");
error1.setText("");
double fromData = Double.parseDouble(currencyInput.getText());
String from = jc.getSelectedItem().toString();
String to = jc2.getSelectedItem().toString();
if(from.equalsIgnoreCase("EUR") && to.equalsIgnoreCase("USD")){
double result =fromData*1.42;
output.setText(result+" "+to);
}else if(from.equalsIgnoreCase("EUR") && to.equalsIgnoreCase("GBP")){
double result =fromData/1.13;
output.setText(result+" "+to);
}else if(from.equalsIgnoreCase("USD") && to.equalsIgnoreCase("EUR")){
double result =fromData/1.42;
output.setText(result+" "+to);
}else if(from.equalsIgnoreCase("USD") && to.equalsIgnoreCase("GBP")){
double result =fromData/1.64;
output.setText(result+" "+to);
}else if(from.equalsIgnoreCase("GBP") && to.equalsIgnoreCase("USD")){
double result =fromData*1.64;
output.setText(result+" "+to);
}else if(from.equalsIgnoreCase("GBP") && to.equalsIgnoreCase("EUR")){
double result =fromData*1.13;
output.setText(result+" "+to);
}else{
error1.setText("FROM AND TO SHOULD BE DIFFERENT");
error.setText("FROM AND TO SHOULD BE DIFFERENT");
resultMsg.setText("");
output.setText("");
}
}catch(Exception ex){
resultMsg.setText("");
System.out.println(ex);
}
}
});
}
}
output:
please write code in java language and do not add any break, continue or goto statements...
VII JAVA ASSIGNMENT. Write a program with a graphical interface that allows the user to convert an amount of money between U.S. dollars (USD), euros (EUR), and British pounds (GBP). The user interface should have the following elements: a text box to enter the amount to be converted, two combo boxes to allow the user to select the currencies, a button to make the conversion, and a label to show the result. Display a warning if the user does not...
This is a python question. from urllib import request import json """ Complete this program that calculates conversions between US dollars and other currencies. In your main function, start a loop. In the loop, ask the user what currency code they would like to convert to And, how many dollars they want to convert. If you scroll down, you can see an example response with the available 3-letter currency codes. Call the get_exchange_rates() function. This function returns a dictionary with...
Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...