English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
1

1.Write a statement that toggles the value of onOffSwitch . That
is, if onOffSwitch is false, its value is changed to true; if
onOffSwitch is true, its value is changed to false.

2. Write a conditional that assigns the boolean value true to the
variable fever if the variable temperature is greater than 98.6

2006-09-13 14:02:03 · 4 answers · asked by ? 1 in Computers & Internet Programming & Design

4 answers

1. if (onOffSwitch==true) onOffSwitch=false;
else if (onOffSwitch==false) onOffSwitch=true;

2. if (temperature<98.6) fever=true;

===
I REALLY advise you to go read your book because this is VERY simple to do

2006-09-13 14:06:55 · answer #1 · answered by Robin C 4 · 0 0

1. Think about it - what are you doing with the truth value? You are making it the *opposite* of itself. There's an operator you use all the time to make things the opposite boolean value - the NOT, or ! operator. So all you need to do is onOffSwitch = !onOffSwitch

2. All of the comparative operators (<, >, etc) return a true or false boolean value - so all you have to do is assign the variable fever the value of the comparison:
fever = (temperature > 98.6)

You could also simply use an if: if(temperature > 98.6) { fever = true }

2006-09-13 21:08:43 · answer #2 · answered by std 3 · 0 0

1. given that onOffSwitch is boolean; this is all

onOffSwitch = !onOffSwitch;

2.
if (temp > 98.6) fever = true;

Isn't this Java 101 stuff?

2006-09-13 21:27:32 · answer #3 · answered by Andy T 7 · 0 0

is this day 1 of java for non-programmers?

2006-09-13 21:10:12 · answer #4 · answered by jake cigar™ is retired 7 · 1 0

fedest.com, questions and answers