• Post Reply Bookmark Topic Watch Topic
  • New Topic

jGRASP InputMismatchException error  RSS feed

 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get this error when I input double or float values for the following code.

Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at shape.main(shape.java:45)
----jGRASP wedge2: exit code for process is 1.

This is my code:


I searched about this problem and I found maybe I have trouble on locale but even when I set the local to default i still experience this error. I also did try with dots (.) and commas (,) and it didn't resolve the problem!
I find it strange when i enter int values the program works but when i enter double or float values it gives error !
Can someone help me on this?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is here:



What type is Scanner expecting?
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:The problem is here:



What type is Scanner expecting?



I have already wrote the Scanner Syntax above
Scanner sc=new Scanner(System.in);
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my own stupid mistake as usual
I got it now
Thanks

nextDouble
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specifically, what type does nextInt() expect?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Savannah Morrison wrote:Oh my own stupid mistake as usual
I got it now
Thanks

nextDouble


Ah, good.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!