Java Reference
In-Depth Information
14
}
15
16
public static void person(Scanner console) {
17
System.out.println("Enter next person's information:");
18
System.out.print("height (in inches)? ");
19
double height = console.nextDouble();
20
getWeight(console, height);
21
}
22
23
public static void getWeight(Scanner console, double height) {
24
System.out.print("weight (in pounds)? ");
25
double weight = console.nextDouble();
26
reportStatus(console, height, weight);
27
}
28
29
public static void reportStatus(Scanner console, double height,
30
double weight) {
31
double bmi = weight / (height * height) * 703;
32
System.out.println("Person #1 body mass index = " + bmi);
33
if (bmi < 18.5) {
34
System.out.println("underweight");
35
} else if (bmi < 25) {
36
System.out.println("normal");
37
} else if (bmi < 30) {
38
System.out.println("overweight");
39
} else {
40
System.out.println("obese");
41
}
42
}
43 }
The methods of a program are like workers in a company. The author of a program
acts like the director of a company, deciding what employee positions to create, how
to group employees together into working units, which work to task to which group,
and how groups will interact. Suppose a company director were to divide work into
three major departments, two of which are overseen by middle managers:
Director
Marketing
administrator
Design
manager
Engineering
manager
Secretary
Architect
Engineer
Administrator
Search WWH ::




Custom Search