Commit 51bdc32

mo <mo.khan@gmail.com>
2019-07-19 22:08:08
complete exercise 7
1 parent 09b7a50
Changed files (2)
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<Person> people = new ArrayList<Person>();
+    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()));
+    }
+  }
 }
src/App.java
@@ -32,6 +32,9 @@ public class App {
         case 6:
           Q6.WeekDay.main(args);
           break;
+        case 7:
+          Q7.Person.main(args);
+          break;
         default:
           System.out.println("Bye");
           System.exit(0);