Careful review and continued discussion of Session #5 and chapter two.
Steps 1, 2, 3 and 4 of the program for computing BMI are: 1. Prompt user for height (feet and inches) and weight (pounds) of the person. 2. Convert to metric - to centimeters and to kilograms. 3. Compute the BMI. 4. Display the person's BMI, along with its CDC category.
Divide a number by 4 and examine the remainder: Is the remainder 0? If not, it is 1 or 2 or 3. Need a 2nd IF ELSE. Is the remainder 1? If not, it has to be 2 or 3. Need a 3rd IF ELSE. Is the remainder 2? If not, is has to be 3! The ELSE is enough!
BMI_Example_SELECT4.txt output indicating which of FOUR roads was chosen given the data item.
The last four letters of the string "UNI PANTHERS" illustrates nicely! ---- HERS H 72 0 <-- Remainder is 0 - Divisible by 4 E 69 1 <-- Remainder is 1 R 82 2 <-- Remainder is 2 - even number, not divisible by 4 S 83 3 <-- Remainder is 3 - ASCII mod 4 is 3
What does the code look like??? theASCIIvalue = ord( theChar ) theRemainder = theASCIIvalue % 4 if theRemainder == 0 : message = "Remainder is 0 - Divisible by 4" else : if theRemainder == 1 : message = "Remainder is 1" else : if theRemainder == 2 : message = "Remainder is 2 - even number, not divisible by 4" else : message = "Remainder is 3 - ASCII mod 4 is 3"