You are on page 1of 2

EXERCISE 10 CHAP 4

1 import java.util.Scanner;
2 public class MeasuredBmi {
3 public static void main ( String [] args)
4 {
5 double weight;
6 double height;
7 double Bmi;
8
9
10 Scanner input1 = new Scanner(System.in);
11 System.out.print("Please Enter the Weight (Kg): ");
12 weight=input1.nextFloat();
13
14 Scanner input2 = new Scanner(System.in);
15 System.out.print("\nPlease Enter the Height (M) ");
16 height=input2.nextFloat();
17
18 Bmi=weight/(Math.pow(height,2));
19
20 if(Bmi < 30)
21 {
22 System.out.printf("Your BMI is OK :%.1f",Bmi);
23 }
24 else
25 {
26 System.out.printf("You are Obese :%.1f",Bmi);
27 }
28 }
29 }
30
Exercise 14 CHAP 4

1 import java.util.Scanner;
2 public class SalaryMarriedCouple {
3 public static void main ( String [] args)
4 {
5 int husband;
6 int wife;
7 int totalSalary;
8
9
10 Scanner input1 = new Scanner(System.in);
11 System.out.print("Please Enter Husband's salary :RM ");
12 husband=input1.nextInt();
13
14 Scanner input2 = new Scanner(System.in);
15 System.out.print("\nPlease Enter the Wife's salary:RM
");
16 wife=input2.nextInt();
17
18 totalSalary=husband+wife;
19
20 if(totalSalary <= 3000)
21 {
22 System.out.print("\nLow :RM"+totalSalary);
23 }
24 else if (totalSalary>3000 && totalSalary<=5000)
25 {
26 System.out.print("\nModerate :RM"+totalSalary);
27 }
28 else
29 {
30 System.out.print("\nHigh :RM "+totalSalary);
31 }
32 }
33 }

You might also like