else if statements
TRANSCRIPT
Today's Computing Challenge• Challenge One: Identify Else If statements in a piece of code and
understand why they are used.
• Challenge Two: Apply an Else IF statement to a piece of code.
• Aspire Three: To nest If statements into the lesson code to increase complexity. Apply different IF statements into the defined problem.
*Additional Extension create your own decision tree including description and comments into the code hint: use // for code comments
Else IF Statements• In the last lesson we created a basic program that …..?
• Can you remember?
• The first part of the lesson was to create a simple
If (condition is true){Then output a message} else do this
IF Statements - RecapJava CodeDrawing of a descision
Else If adds more possibilities or choices
Java CodeStart a new java application in Netbeans and call it esleif
Notice that we did not print out the grade until after the If statement block. This is because the result is assigned to the variable grade until the end.
Extension: Can you include some help for the user in the output window?
Your turn! Adapt the code and expand!Include more ELSE IF statements to complete the grading system
Once complete take a print screen and upload to your OneNote.
Can you adapt the code to become more user friendly!
Can you add comments to your code to explain the process?Take new screen shot and upload to OneNote
Your turn! Adapt the code and expand!Can you adapt the code and create a new appcalled ‘temperature’ Change the Grades to the following 1. Steaming hot = temperature above 92 degrees Celsius2. Very hot = temperature above 72 degrees Celsius3. Hot = temperature above 62 degrees Celsius4. Very Warm = temperature above 42 degrees Celsius5. Warm = temperature above 22 degrees Celsius6. Cold = temperature above 2 degrees Celsius
Plenary• What variables did you create?
• How did you declare that variable in Java?
• Inside the If statement what does the >= mean?