Answer to Question #4710 in Java | JSP | JSF for David Hughes

Question #4710
import java.util.Scanner;
import java.text.NumberFormat;
import java.text.DecimalFormat;
* Write a description of class CurrencyUI here.
* @author (your name)
* @version (a version number or a date)
public class CurrencyUI
* An example of a method - replace this comment with your own
public double runConversions()
// put your code here
double input;
String input2;

System.out.println("Welcome to the currency converter.\n");
System.out.print("Enter the amount of American dollars to convert > ");

input = scan.nextLine();

System.out.println("Mexican Pesos [P]/nEuropean Euros [E]\nChinese Yuan [Y]\nCanadian Dollars [D]\n\nEnter the currency to convert to > ");

input2 = scan.nextLine();

Why won't this compile?
Expert's answer
1. line 18: add "Scanner scan = new Scanner(;"

2. line 19,25:

input should be not double, but String or use this


input = scan.nextDouble();

} catch(InputMismatchException e){



P.S. also, don't forget about NoSuchElementException and IllegalStateException, when You use scan.nextDouble() and scan.nextLine().

Good luck =)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
17.04.12, 14:25

Sorry for delay then. You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

14.04.12, 07:24

I'd like to personally thank you. This may or may not have helped, if it were answered a few months ago when I was still taking the JAVA course I was in, but I do have to say "better late than never!"

Leave a comment

Ask Your question

New on Blog