Java Help? AP Computer Science actually...SO help?

Answer this question

  • Java Help? AP Computer Science actually...SO help?


Answer #1 | 02/01 2014 11:37
There are 3 ways of determining the number of entries: 1) Ask the user in advance how many entries there will be. This, of course, requires the user to know that answer. 2) After each number is entered, ask the user if they want to enter another number. This, of course, is tedious -- having to answer the question every time. 3) Have a "sentinel" value -- a number that cannot be a valid entry. This depends on what the numbers represent. If they are scores on a test then you won't have a negative score, so a sentinel value can be -1. If both positive and negative numbers are allowed, perhaps a huge number like 999 million can be the sentinel value. If every possible number is actually possible, then you can combine methods 2 & 3. Have an unlikely number as the sentinel, but then ask the user if that number should be entered or does the user want to stop entering numbers. For both 2 and 3, the program would have a counter to keep track of the number of entries. Another possibility for the sentinel value is if the entry is a character string. So the user can enter X if they want to stop, but if an X isn't found then the string has to be converted to a number. Some languages always return a string that would have to be converted to a number (and, technically, everything entered on the keyboard is a string).
Positive: 100 %
Answer #2 | 02/01 2014 11:42
If you allowed to use other programming lang. than YAY! if not sorry… if you want to do it while the user type then you have to use AJAX if not use PHP or JavaScript! Look up AJAX it shows you how. ================== ==================
Positive: 0 %

Possible answer