wood burning stoves*
The moose likes Beginning Java and the fly likes Incompatible types error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Incompatible types error" Watch "Incompatible types error" New topic
Author

Incompatible types error

Joniela Geldenhuys
Greenhorn

Joined: Aug 24, 2011
Posts: 10
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

Joined: Oct 13, 2005
Posts: 38007
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Incompatible types error
 
Similar Threads
Need help with username and password validation
Project Help
Having trouble understanding an error code i keep getting. Please help!
Project Help
Class Help!