Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Incompatible types error

 
Joniela Geldenhuys
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helo I've been struggling for hours now!! I'm doing a java course and I must code an interactive balancing calculator! my textbook does not explain the work very nice so now I'm stuck!!!
This is what I coded but when I compile they give me 4 errors saying incompatible types! I don't know what I'm doing and I feel so stupid!! Please help!!

 
Campbell Ritchie
Sheriff
Pie
Posts: 48963
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which book are you using, and how old is it?
Why are you using Readers, rather than a Scanner? A Scanner will give the input directly converted to the Java™ type required. Rather than your reading the line as a String and trying to assign that to the openingBalance amount, which is a double, so the compiler cannot achieve that (hence your error message), you can get the input converted directly without having to mess about with parseXXX method. So you can get the input in the correct type for money, which is not float nor double, but BigDecimalAnd there is a serious error in that code. So as not to let people think you are getting that code without any effort, I shall "forget" to correct that error (which appears twice). And I have respelt some of your variable names.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic