I'm sort new to Java programing, and I created this simple converter, but when I try to complie it, it gives me an exception error, could some one tell me how to correct this code.
Code:import java.text.*; import javax.swing.*; public class Converter { private final static double EURO = .8295577, YEN = 115.614, CAD = 1.17781; public static void main (String[] args) { String input =null; double US= 0.0; DecimalFormat twoPrecision = new DecimalFormat("0.00"); input() = 0 try{ US = Double.parseDouble (input); System.out.print("US to Euro: "); System.out.println(twoPrecision.format(US * EURO)); US = Double.parseDouble (input); System.out.print("US to Yen: "); System.out.println(twoPrecision.format(US * YEN)); US = Double.parseDouble (input); System.out.print("US to Cad: "); System.out.println(twoPrecision.format(US * CAD)); } catch(NumberFormatException e) { JOptionPane.showMessageDialog(null, "You must enter a number", "Input data error", JOptionPane.ERROR_MESSAGE); } } }


Reply With Quote


Bookmarks