Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

And vice versa these are the conversion rates needed for this program EUR: USD *

ID: 661052 • Letter: A

Question

And vice versa these are the conversion rates needed for this program EUR: USD * 0.879872; AUD USD * 1.233162; SGD : USD * 1.319025 You must create a program named CurrencyConversion.java that converts money between the following currencies. Given one of the three currencies, the program should convert the input amount into one of the other currencies. For example, if you input one (1) U.S. dollar, and you decide to convert that one dollar to a pound, then the output should be .60. Using the JOptionPane GUI, do the following. Prompt the user for the currency code type. Prompt the user for the amount of that currency. Prompt the user for the currency code that the entered amount must be converted to. Display the results in a JOptionPane message box. CurrencyConversion Points Description Standard header included 1 Must contain program's name, student name, and description of the program Program compiles 1 Program does not have any error Program executes 2 Program runs without any error Use JOption Pane 8 Use JOption Pane for input and output Compute conversion 8 Uses logic and correct formula to compute results

Explanation / Answer

comments added

import javax.swing.*;
import javax.swing.JOptionPane;
public class CurrencyConverter
{
public static void main(String[] args)
{
JFrame currencyframe = new JFrame("Currency Converter"); //declaring frame
String currency1 = JOptionPane.showInputDialog(currencyframe, "Enter amount to convert");//getting input from user that is currency
String code1 = JOptionPane.showInputDialog(currencyframe, "Enter currency code 1. EUR 2.AUD 3.SGD"); //getting currency code
int currency = Integer.parseInt(currency1);
int code = Integer.parseInt(code1);
double total=0;
//calculating results
if(code==1){
total =currency * 0.879872;
}
else if(code==2){
total=currency * 1.233162;
}
else if(code==3){
total = currency * 1.319025;
}
//outputting results to user
JOptionPane.showMessageDialog ( null, "The converted amount is "+total );
System.exit(0);
}
}