Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with noob java program

 
lucas hall
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
greetings every one I am very new to the programming life and have been trying to learn on my own. I am having some problems with the output of this very simple program any ideas on where I went wrong. Please don't judge to harsh ahhahahh trying to learn as I go. Thank you




 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some problems with the output of this very simple program any ideas on where I went wrong.


You forgot to mention, your expected output.
 
Runrioter Wung
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I correct the line 21 and line 41,you can compile it and run it.Look at the output.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runrioter Wung wrote: . . . I correct the line 21 and line 41,you can compile it and run it.Look at the output.
You haven’t corrected anything. You haven’t even found the errors.
[edit]YOu have changed 4 to 100, but that doesn’t seem to make any difference. Even it I put in numbers which I think will get acceptance, it won’t accept me. I copied and pasted what you posted.[/edit]
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You really need to find out about code conventions, and spread out your code. You can find out about code conventions here, though that is an old document, and I prefer the different identation conventions here. By indenting code, you make it much easier to read, and you also make it easier to find mistakes because of unbalanced {}. As it is, you have several lines squashed into one, which makes your code really difficult to read.
Also you will find you ought to avoid if (...) return true; else return false;
You ought to avoid numbers in your code. If you need to use 100, you should give it a name as a constant, like this public static final int BOILING_WATER = 100; That makes it obvious what the 100 means. I can’t tell what 100 means by reading the code. I can’t tell what values are supposed to be accepted and what rejected.

Why are you making everything static? Is it because you have a book which teaches you to put everything into the main method?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic