Register|Login

Have a question? Click here to ask the community.

Tutorial 13 – Else If Statements

| In: 13. Else If Statements | 7,067 views

Video Tutorial


Video Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!--?php 
//File Description: PHP Else If Statements
 
/*
if (temp < 60 degrees) {
    It is cold outside
}
elseif (temp >= 60 degrees && temp <= 80 degrees) {
    It is warm outside
}
elseif (temp > 80 degrees && temp < 100 degrees) {
    It is hot outside
}
else {
    It is extremely hot outside
}
*/
 
// Example
$temp = 50; // holds the temperature
 
if ($temp < 60) {
    echo "It is cold outside";
}
elseif ($temp >= 60 && temp =< 80) {
    echo "It is warm outside";
}
elseif ($temp > 80 && $temp < 100) {
    echo "It is hot outside";
}
else {
    echo "It is extremely hot outside";
}
?>



4 Responses to Tutorial 13 – Else If Statements

Avatar

Maggie

May 30th, 2014 at 2:33 pm

1 import java.lang.System 2 import java.lang.String 3 import java.io.InputStreamReader 4 import java.io.BufferedReader 5 import java.io.IOException 6 7 public class Month 8 primary(String[] args)throw IOException 10 The month of january”) 22 else if (month ==2) Feb”) 24 else if (month ==3) else if (month ==4) else if (month ==5) else if (month ==6) else if (month ==7) This summer”) 34 else if (month ==8) else if (month ==9) else if (month ==10) else if (month ==11) else if (month ==12) else 46System.out.println(“Invalid Number”) 47 48

Avatar

Alun J

May 30th, 2014 at 2:33 pm

Hey, Im inside a CS class so we needed to write a technique that returns a string that’s the amount succumbed another base from 2 to 16. it began off bad and also got worse when i stored trynig to fix for errors and i believe my strategy was problematic. My teacher doesn’t really train us much, so any assistance is much appreciated. thanks. ___________________________________________________________________________________ private static String fromBaseTenToBaseY(int num, int base) return answer ___________________________________________________________________________________

Avatar

Matthew S

May 30th, 2014 at 2:35 pm

1.Define a listing of 5 constant words within an set up code. Title their list NUMS. 2.Define 2 storage words, named AVG as well as 3.Use set up instructions to compute the typical from the 5 constant words. You might only connect to the words while using label NUMS as well as an offset, i.e. you can’t connect to the words directly utilizing their memory addresses. For instance, NUMS+2 may be the second constant within the list. 4.Keep average within the space for storage you understood to be AVG FOR Bonuses: 5.Now count the number of even amounts you will find within the list. Store this value within the space for storage you understood to be EVEN. Remember, that the code should work with any listing of amounts not merely one specific listing of constants. Therefore, with this part you have to USE the idea of LOOPS and when-ELSE claims. This is how we’d do that in Python: nums = [12, 13, 8, 29, 28] even= i= as i<5: —-if nums[i]%2==0: ——–even = even+1 —-i = i+1

Avatar

Joe

April 20th, 2015 at 4:41 am

Shouldn’t lines 25 and 28 be >= not just > ? If its 60 deg it will be extremely hot outside the way its written.

Comment Form

You must be logged in to post a comment.