# beginner here...help please

Printable View

• 09-15-2009, 05:24 PM
shroomiin
beginner here...help please
hello everyone. im new here and also a beginner to java. I have a college professor who does not explain anything and just expects us to know how. so i have a pretty simple question here.

ok were just doing pseudocode right now not actual java. but im stuck on a concept. the question is...in pseudocode...

Read some grades until a -999 is entered. find and display the lowest of these grades. This is what i have so far..

Begin-
Read grades
While not equal to -999
.....

thats where i am stuck, not sure what to say after that haha. so please help a noob out over here! thanks
• 09-15-2009, 05:28 PM
Fubarable
Here's a trick: Say you're a scribe with nothing more than a pencil and a pad of paper, and someone is telling you numbers until they tell you -999, and given this information you must tell him at the end the lowest number.

The key here is to think of the steps required to do something like this without a computer, with just the paper and pad as noted above. Try to describe the exact steps required, break the steps down into their most atomic sub-step, and from these steps the pseudocode (and eventually the code) will flow naturally. Well, how about giving it a go? Much luck!

edit: oh, by the way, get used to having to learn because of or despite your teachers. You'll find that in college and in life, the ultimate responsibility for learning is not the teacher's but yours. You can do it but it may require more effort. Again, luck.
• 09-15-2009, 05:31 PM
shroomiin
i just dont understand how to use the while statements well enough. i dont know what to say because i dont know what to compare the lowest number to, you know what i mean?
• 09-15-2009, 05:33 PM
Fubarable
Forget "while", forget Java and computers exist. Again, how would you do this with pencil and paper.
• 09-15-2009, 10:17 PM
shroomiin
well i would take down all the numbers to be recorded...go through them and find the lowest number...

but thanks in advance for the help/advice
• 09-15-2009, 11:45 PM
Fubarable
Again, find the smallest sub steps here, the "atomic" steps. Myself, I would:
ask the fellow for a number
if it's not the sentinel number (-999), write it down.
Ask for another number.
if it's not the sentinel number (-999), and if it's lower then the current number, write it down.
Ask for another number.
if it's not the sentinel number (-999), and if it's lower then the current number, write it down.
Ask for another number.
if it's not the sentinel number (-999), and if it's lower then the current number, write it down.
Ask for another number.
if it's not the sentinel number (-999), and if it's lower then the current number, write it down.
... (see anything "looping" here?)
until the sentinel number has been reached, then return the last number I've written down.

Next I'd take these steps and try to create a loop that would simplify this.
• 09-16-2009, 12:06 AM
shroomiin
wow thanks. that really helped me out, i couldnt see it like that for some reason...heres what i came up with..

Begin-
Smallest number=j
Prompt user for grade
While grade is not equal to -999
Grade =j
Prompt user for grade2
If grade2 is<j
Then grade2=j
Prompt user for grade3
If grade3 is<j
Then grade3=j
End while
Display J
-end.

thats probably still wrong but not as bad haha