import java.util.* ;
public class CurrencyConverterTester
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in) ;
System.out.println("How many euros is one dollar?") ;
String input = scanner.nextLine() ;
double rate = Double.parseDouble(input) ;
CurrencyConverter converter = new CurrencyConverter(rate);
boolean done = false;
while (!done)
{
System.out.println("Dollar value (Q to quit)") ;
input = scanner.nextLine() ;
double amount = Double.parseDouble(input) ;
if (input.equalsIgnoreCase("Q"))
done = false;
else {
double exchange = converter.convert(amount);
System.out.println(amount + " dollars = " + exchange + " euro");
}
}
}
}
basically when i press q or Q i get an error
Exception in thread "main" java.lang.NumberFormatException: For input string: "q"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
at java.lang.Double.parseDouble(Double.java:510)
at CurrencyConverterTester.main(CurrencyConverterTester.java:23)
Java Result: 1