• Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic conversion program - some unexpected results  RSS feed

 
Jose Castillo
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, I am making a basic conversion program in java for one of my classes, and am getting a few odd answers. Here's my code:



I'm getting a few errors:

For int meters->inches, I got 156 instead of an expected 157.
For int Cel - > Far, I got -8 instead of an expected -40
For int Far - Cel I got 0 instead of an expected 100.
I also got an error: Failed: Non-private constructor method: public conversion()


Any pointers would be much appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer in 3 seconds: what's the integer value of 5/9?
 
Jose Castillo
Greenhorn
Posts: 13
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Answer in 3 seconds: what's the integer value of 5/9?


Oh, duh, zero. Thanks for pointing out that silly mistake I made. That solved it
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have similar problems with inches to meters.

By the way, you can get away without declaring a local variable
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!