java – I can't figure out what the error is: InputMismatchException

Question:

my Java code:

import java.io.File; 
import java.io.IOException;
import static java.lang.System.out;
import java.util.Scanner;
import java.util.logging.Logger;
class DoPayroll 
{ 
   public static void main(String args[]) throws IOException 
   { 
        Scanner diskScanner = new Scanner(new File("d:\\EmployeeInfо.txt")); 
        for (int empNum = 1; empNum <= 3; empNum++) 
        { 
            payOneEmployee(diskScanner); 
        } 
    } 
    static void payOneEmployee(Scanner aScanner)    
    { 
       Employee anEmployee = new Employee(); 
       anEmployee.setName(aScanner.nextLine()); 
       anEmployee.setJobTitle(aScanner.nextLine()); 
       anEmployee.cutCheck(aScanner.nextDouble()); 
       aScanner.nextLine(); 
    } 
    private static final Logger LOG = Logger.getLogger(DoPayroll.class.getName());
}
public class Employee 
{
    private String name; 
    private String jobTitle; 
    public void setName(String nameln) 
    { 
    name = nameln; 
    } 
    public String getName()  
    { 
      return name; 
    } 
    public void setJobTitle(String jobTitleln) 
    { 
       jobTitle = jobTitleln; 
    } 
    public String getJobTitle() 
    { 
        return jobTitle; 
    } 
    public void cutCheck(double amountPaid) 
    { 
        out.printf("Выплатить служащему %s ", name); 
        out.printf("(%s) ***$", jobTitle); 
        out.printf("%,.2f\n", amountPaid); 
    } 
    private static final Logger LOG = Logger.getLogger(Employee.class.getName());
}

There is also an EnployeeInfo.txt file

Барри 
Курьер 
5000,00 
1 Джейн 
Программист 
1 7000,00 
1 Кэтти 
1 Кассир 
5 10000,00 

Found a Java file, but it throws an error: InputMismatchException. Please tell me how to fix

Answer:

The format of the real number depends on the current locale. In some languages, the fractional part is separated by a period, in others by a space. In order not to depend on the settings of the operating system in which the program is launched, set the used locale explicitly:

Scanner diskScanner = new Scanner(new File("EmployeeInfo.txt"));
diskScanner.useLocale(new Locale("ru"));
Scroll to Top