0
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

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by wowz
0

lol, as soon as i posted i figured out what was wrong!!
i had to move lines 19 and 20 into the else {}

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.