• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help with noob java program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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




 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I correct the line 21 and line 41,you can compile it and run it.Look at the output.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic