• Post Reply Bookmark Topic Watch Topic
  • New Topic

error in Eclipse and I don't know how to resolve it  RSS feed

 
John Locke
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is: "total cannot be resolved or is not a field". It's line 15.

 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because you have a '.' rather than a '+' just before total.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to the Ranch.
 
John Locke
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! That was the correct fix.
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Locke wrote:Thank you! That was the correct fix.

John, strange that you got fixed with "+".
It should work only with "," right before total since you are using printf.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:
John Locke wrote:Thank you! That was the correct fix.

John, strange that you got fixed with "+".
It should work only with "," right before total since you are using printf.

Well spotted. I didn't notice the printf statement.

@John Locke
My answer would stop the compilation error but the program won't display the correct result. Liutauras Vilda is correct, you should replace the '.' with a ','.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I shall take some of the blank lines out of your code because you don't need them and double‑spaced code isn't easier to read. You also don't need the println call. The more print statements you can cram into one the better, because there is a performance overhead to the output. Replace the println statement with a strategically‑placed &n before the second quote mark.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!