|
Until you sign up you can't do much. Yes, it's free.
|
|
|
|
|
|
|
 | / / / Viewing Topic
|  |
|
|
UltimaTaz
Guru
Patron
|
Looks like it's a fail-fail test.
------- MadiJune agreed to be my wife. :) My God is the Earth In the presence of bullshit, I tend to tilt my head
|
12:57 pm on Oct. 29, 2008 | Joined: Aug. 2007 | Days Active: 451 Join to learn more about UltimaTaz Maryland, United States | Straight Male | Posts: 19,285 | Points: 23,864
|
|
| |
|
|
Ethryx
Soothsayer
Patron
Tech Support Leader
|
The function will return true if the score is between 0 and 100, including 0 and 100. If its lower then 0 or higher then 100 then it will return false.
------- Peek-a-boo! DragDrop Image Hosting Fast. Free. Easy.
|
12:57 pm on Oct. 29, 2008 | Joined: Jan. 2007 | Days Active: 526 Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,853 | Points: 13,224
|
|
| |
|
|
|
|
Ethryx
Soothsayer
Patron
Tech Support Leader
|
Quote: from Majo at 4:03 pm on Oct. 29, 2008
Quote: from Ethryx at 3:57 pm on Oct. 29, 2008
The function will return true if the score is between 0 and 100, including 0 and 100. If its lower then 0 or higher then 100 then it will return false.
But how does that validate the value? I mean...what does that do? True/False doesn't get printed out so what happens? You call the method and then...it checks...but then what happens with/to the true/false? 
Let me put this into a real example for you: int Score = 85; boolean ScoreValid; ScoreValid = validateScore(Score); if(ScoreValid == true) { // put coding here when the user entered a valid score between 0 and 100 } else { // this would be an error since the score is either lower then 0 or higher then 100. tell the user to re-enter the score } ** As you can see, the function validateScore (which you wrote the coding to above) is going to return a true/false value to, in this case, the variable ScoreValid based on the integer that is passed too it (Score). If the variable Score contains a number between 0 and 100, ScoreValid will be true because validateScore will set it to true. If it is below 0 or above 100, ScoreValid will be false because validateScore will set it to false. The user of this java program does not see this true/false value. This is just a way of checking that a valid 'score' was submitted and not something else. Hope that helps, let me know if you still don't understand. Post edited at 1:29 pm on Oct. 29, 2008 by Ethryx
------- Peek-a-boo! DragDrop Image Hosting Fast. Free. Easy.
|
1:28 pm on Oct. 29, 2008 | Joined: Jan. 2007 | Days Active: 526 Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,853 | Points: 13,224
|
|
| |
|
|
matto
Enlightened One
Patron
Tech Support Leader
|
'boolean' is a data type that holds two possible values: true or false. Just like 'int' and 'char' are kinds of data types. This means that any boolean value, once computed, will have a value of true or false. Some examples of boolean values: true false (x > 7) (true if x is > 7, false if x<=7) validateScore(100) (true) validateScore(30) (true) validateScore(-5) (false) The method 'validateScore' returns a boolean value to wherever it is called. These boolean values can be used in if() statements and while() statements, and places like that. Within the () there must be a boolean value. Post edited at 6:26 pm on Oct. 29, 2008 by matto
------- "Strong am I with the Force, but not that strong. Twilight is upon me, and soon, night must fall. That is the way of things. The way of the Force." --Yoda
|
6:22 pm on Oct. 29, 2008 | Joined: Aug. 2007 | Days Active: 437 Join to learn more about matto California, United States | Male | Posts: 8,818 | Points: 16,846
|
|
| |
|
|
|
| Looking for something else?
|
|
|
|
|
|
 | / / / Viewing Topic |  |
|