Java issue with input -


today trying basic exercise , faced in problem :

exception in thread "main" java.util.inputmismatchexception     @ java.util.scanner.throwfor(unknown source)     @ java.util.scanner.next(unknown source)     @ java.util.scanner.nextdouble(unknown source)     @ main.main(main.java:14) 

this code :

import java.util.scanner;  public class main {     public static void main(string[] args) {         scanner input = new scanner(system.in);         double salary = 0;      // salary excluded tax         int tax = 0;            // % of tax         double taxtot = 0;      // amount of tax         double totsalary = 0;   // salary tax          system.out.println("salary, please : "); //input salary         salary = input.nextdouble();              if (salary <= 15000) {                          // <=15000             tax = 10;         } else if (salary>= 40000 && salary < 60000){       // >=40000             tax = 20;         } else {                                            // on > 60000             tax = 30;         }          taxtot = salary / 100*tax;         totsalary = salary - taxtot;         system.out.println("your tax : " + taxtot + " salary : " + totsalary);     } } 

try example

scanner scanner = new scanner(system.in).uselocale(locale.us); 

there difference between 5,0 , 5.0


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -