Question
Java swing The question :Currency Conversion (use swing components). Prompt a user to enter an amount in dollars. Output the conversions into euros, pounds and
Java swing
The question :Currency Conversion (use swing components). Prompt a user to enter an amount in dollars. Output the conversions into euros, pounds and rubles. Use the following conversions: pound - .64; euro - .91; ruble 61.73.
My code below does not compile. Please assist.
import javax.swing.JOptionPane; import java.text.DecimalFormat;
public class KMCurrencyConversionSwing { public static void main(String[] args) { // declare and construct variables
double dollars, pounds, euros, rubles;
// Assigning Values pounds = 0.64; euros = 0.91; rubles = 61.73; DecimalFormat twoDigits = new DecimalFormat("####.00");
//print prompts and get input System.out.println("\tCurrency Conversion:");
dollars = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter the dollar amount:"));
// calculations
pounds = pounds * dollars; euros = euros * dollars; rubles = rubles * dollars;
// output JOptionPane.showMessageDialog(null, "YOUR DOLLAR AMOUNT OF " + twoDigits.format(dollars) + " is equal to " + twoDigits.format(euros) + " euros, " + twoDigits.format(pounds) + "pounds and " + twoDigits.format(rubles)+ "rubles." , "Currency Convertor",JOptionPane.PLAIN_MESSAGE);
System.exit(0); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started