Results 1 to 12 of 12
Thread: amateur
- 04-13-2012, 10:43 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
- 04-13-2012, 12:08 PM #2
Re: amateur
What is meant by your subject line amateur?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-13-2012, 01:05 PM #3
Re: amateur
That could be an arithmetic expression that returns the value of the sentinel variable minus 1
A usage:
y = x - 1If you don't understand my response, don't ignore it, ask a question.
- 04-13-2012, 01:20 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: amateur
I am only new at programming and am been asked to write a program that allows a user to enter a series of numbers and when the sentinel -1 is entered the largest number is printed out on the screen, but i am stuck with what the sentinel means and how i would use same; this is my program so far but i cant find my way out any help greatly appreciated
public class sentinel {
public static void main (String[]args) {
int x;
Screen.message("PE enter series of numbers");
do
x=keyboard.readInt();//error: cannot find symbol
while(x!=-1);
}
}
- 04-13-2012, 01:27 PM #5
Re: amateur
What does google give for the meaning of sentinel?
Can you post the definition you get and then ask questions if you don't understand it.
Does your code work as you want it to? If not, please explain what happens that is not what you want.If you don't understand my response, don't ignore it, ask a question.
- 04-13-2012, 02:04 PM #6
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: amateur
Sentenal=In programming, a special value that is used to terminate a loop. The sentinel value typically is chosen so as to not be a legitimate data value that the loop will encounter and attempt to perform with. For example, in a loop algorithm that computes non-negative integers, the value "-1" can be set as the sentinel value as the computation will never encounter that value as a legitimate processing output.
In My program i wish to enter 5 numbers and have the screen only output the highest number!
- 04-13-2012, 02:10 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: amateur
You still haven't answered the question from reply #1.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-13-2012, 02:12 PM #8
Re: amateur
Getting 5 numbers is different than getting numbers UNTIL the user enters a number with a value of -1.
You would use a for loop that loops 5 times for that.
To find the largets: In the loop you would need to use a if statement to compare what the user entered against the value of the current largest number. If new is larger, then save the new one as the current largest.If you don't understand my response, don't ignore it, ask a question.
- 04-13-2012, 02:21 PM #9
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: amateur
thanks for your help, am going to try that- the original question was - (a)write a program that allows a user to enter a series of numbers and when the sentinel -1 is entered the largest number is printed out on the screen.!...still not exactly sure how to implement this in the program!
- 04-13-2012, 02:25 PM #10
Re: amateur
The code in post#4 uses a sentinel to stop getting user input.
If you don't understand my response, don't ignore it, ask a question.
- 04-13-2012, 02:33 PM #11
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: amateur
dont understand your answer, but maybe you can help in explaining why the program is issuing the following message
x=keyboard.readInt();//error: cannot find symbol
- 04-13-2012, 02:39 PM #12
Similar Threads
-
An amateur Java Tutorials Site
By elasolova in forum Reviews / AdvertisingReplies: 1Last Post: 01-18-2008, 09:23 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks