• Post Reply Bookmark Topic Watch Topic
  • New Topic

Input double value using nextline()  RSS feed

 
John Joe
Ranch Hand
Posts: 443
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My desired output look like this

Enter three sides for a triangle: 1.2 3.5 6
The area of the triangle is xxx.x


However I get error after i typed 3 inputs

Code





Error

 
Norm Radder
Rancher
Posts: 2240
28
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the nextLine method will return everything entered up to the Enter key.
If you want to enter the data on one line use the next or nextDouble method to read individual tokens
If you want to use the nextLine method, press Enter after every number has been entered.
 
John Joe
Ranch Hand
Posts: 443
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!