From 51bdc328012d748805a229e0d8a9664f865876c5 Mon Sep 17 00:00:00 2001 From: mo Date: Fri, 19 Jul 2019 16:08:08 -0600 Subject: complete exercise 7 --- src/Q7/Person.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Q7') diff --git a/src/Q7/Person.java b/src/Q7/Person.java index c447cc2..0e37d53 100644 --- a/src/Q7/Person.java +++ b/src/Q7/Person.java @@ -1,5 +1,7 @@ package Q7; +import java.util.*; + public class Person { private double bmi; private double height; @@ -67,4 +69,25 @@ public class Person { private void updateBMI() { this.setBMI((this.weight * 703) / Math.pow(height, 2)); } + + public static void main(String[] args) { + ArrayList people = new ArrayList(); + people.add(new Person("Andrew", 125.5, 55.1)); + people.add(new Person("Boyd", 150.0, 67.0)); + people.add(new Person("Cathy", 135.0, 72.3)); + people.add(new Person("Donna", 190.0, 64.0)); + + System.out.println(String.format("%-20s Weight Height BMI Category", "Name")); + System.out.println("-----------------------------------------------"); + for (Person person : people) { + System.out.println( + String.format( + "%-20s %+5.1f %+6.1f %+3.0f %s", + person.getName(), + person.getWeight(), + person.getHeight(), + person.getBMI(), + person.getCategory())); + } + } } -- cgit v1.2.3