The formula for calculating BMI in Metric Units is:
BMI = Weight in l<g/(Height in Meters* Height in Meters)
For example, let us consider height= 1.50m and weight= 90.0kg
BMI = 90.0 / (1.50 * 1.50) = 40.0 (You are Obese).
Here is a sample output of the BMI Calculator program:
Enter your weight in kg: 90.0
Enter your height in cm: 1.50
Your BMI value: 40.0
Status:
You are Obese
Question Two
[8 Marks]
Write a Java program that will accept two numbers as input from the keyboard and find the
largest of the two Numbers
Question Three
Write a Java program to sum even numbers between startNo and endNo.
You may either use afar statement or any other looping statement in Java.
The following should be programmed:
[8 Marks]
Two numbers (startNo and endNo) should be accepted as input from the keyboard.
(a) If startNo is less than 0 then the program should print "startNo cannot be less than 0"
and the program will end. (2 Marks).
(b) If end No is less than 0 then the program should print "endNo cannot be less than 0" and
the program will end. (2 Maries).
(c) If end No is greater than 9 then the program should print "end No cannot be greater than
9" and the program will end. (2 Marks).
(d) But, if the right numbers (startNo and end No) are entered ie any two numbers within 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, then the sum of even numbers between startNo and EndNo will be calculated
and the program will printout "Sum of Even Numbers=" sum Even. (2 Marks).
Sample output 1:
Input: Enter 2 Numbers separated with a space (startNo and endNo): -3 7
Output: startNo cannot be less than 0
Sample output 2:
Input: Enter 2 Numbers separated with a space (startNo and endNo): 2 -9
Output: end No cannot be less than 0
Sample output 3:
Input: Enter 2 Numbers separated with a space (startNo and endNo): 2 20
Output: end No cannot be greater than 9
Sample output 4:
Input: Enter 2 Numbers separated with a space (startNo and endNo): 2 8
Output: Sum of Even Numbers= 20
[Hint: Even numbers from 2 to 8 are: 2,4,6,8, therefore Sum = 2+4+6+8=20]
---
---
THE END ---
---
---
5