• Post Reply Bookmark Topic Watch Topic
  • New Topic

bad operand types for binary operator '/'  RSS feed

 
Richard Scott
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,
so here is my code im trying to get working. don't know what im doing wrong any help would be great! thanks!
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have given your Scanner a very poor name. Call it something like inScan and the reason for the error will become obvious (I hope). You do not need two Scanners pointing at System.in. You are using them wrongly. You have to call their methods. Have a look at the documentation, which has almost exactly what you want on the first page.
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will suffer other errors because you have a double which you are trying to use as an int. Try the formula for the distances which used to be on the back of the Highway Code, instead:-
d = s + s² ÷ 20.
You can express that as ints because you should always use y × y to calculate y²
 
Brian Schuetz
Greenhorn
Posts: 25
Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also have "if(stoppingDistance = distance)"

You want to use the double equals for comparing "if(stoppingDistance == distance)"

The single equal sign is actually an assignment operator.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!