В чем здесь ошибка? Я получаю inputmismatchexception - PullRequest
0 голосов
/ 01 октября 2019

Я пишу небольшую программу, но она генерирует исключение inputmismatchexception. enter image description here Что здесь не так? `Ошибка измерения следующая.

What is the three letter currency symbol for your travel destination? How many  are there in 1 USD? MCX
Exception in thread "main" java.util.InputMismatchException
at java.base/java.util.Scanner.throwFor(Unknown Source)
at java.base/java.util.Scanner.next(Unknown Source)
at java.base/java.util.Scanner.nextFloat(Unknown Source)
at TripPlanner.main(TripPlanner.java:30)
    {
        System.out.println("Welcome to Vacation PLanner!");
        System.out.print("What is your name? ");

        Scanner input = new Scanner(System.in);
        String name = input.nextLine();

        System.out.print("Nice to meet you " + name + ", where are you travelling to? ");
        String city = input.nextLine();

        System.out.println("Great! " + city + " sounds like a great trip");
        System.out.println("***********");

        System.out.print("How many days are you going to spend travelling? ");
        int days = input.nextInt();

        System.out.print("How much money, in USD, are you planning to spend on your trip? ");
        int money = input.nextInt();

        System.out.print("What is the three letter currency symbol for your travel destination? ");
        String currencySymbol;
        currencySymbol = input.nextLine();

        System.out.print("How many " + currencySymbol + " are there in 1 USD? ");
        float exchangeRate = input.nextFloat();
    }
}`
...