diff options
| -rw-r--r-- | src/App.java | 9 | ||||
| -rw-r--r-- | src/Q6/WeekDay.java | 8 | ||||
| -rw-r--r-- | src/Q7/Person.java | 1 | ||||
| -rw-r--r-- | src/Q7/README.md | 72 |
4 files changed, 64 insertions, 26 deletions
diff --git a/src/App.java b/src/App.java index 111fe07..fe1d3f3 100644 --- a/src/App.java +++ b/src/App.java @@ -1,6 +1,15 @@ package ca.mokhan.comp268; import Q1.*; +import Q10.*; +import Q2.*; +import Q3.*; +import Q4.*; +import Q5.*; +import Q6.*; +import Q7.*; +import Q8.*; +import Q9.*; import java.util.Scanner; public class App { diff --git a/src/Q6/WeekDay.java b/src/Q6/WeekDay.java index 7c79e8b..db77c17 100644 --- a/src/Q6/WeekDay.java +++ b/src/Q6/WeekDay.java @@ -15,6 +15,13 @@ public class WeekDay { new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; private static final int[] MONTHS = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + /** + * Returns the day of the week that a certain date falls on. + * + * @param day the day of the month + * @param month the month of the year + * @param year the year + */ public String getWeekDay(int day, int month, int year) { this.ensureValidDate(year, month, day); return DAYS[daysSinceEpoch(day, month, year) % 7]; @@ -46,6 +53,7 @@ public class WeekDay { throw new IllegalArgumentException(); } + /** The entry point to the console application. */ public static void main(String[] args) { Scanner in = new Scanner(System.in); diff --git a/src/Q7/Person.java b/src/Q7/Person.java index aaca8af..062a7a3 100644 --- a/src/Q7/Person.java +++ b/src/Q7/Person.java @@ -130,6 +130,7 @@ public class Person { this.setBMI((this.weight * 703) / Math.pow(height, 2)); } + /** The entry point to the console application. */ public static void main(String[] args) { ArrayList<Person> people = new ArrayList<Person>(); people.add(new Person("Andrew", 125.5, 55.1)); diff --git a/src/Q7/README.md b/src/Q7/README.md index 7eedc51..0ccf783 100644 --- a/src/Q7/README.md +++ b/src/Q7/README.md @@ -5,41 +5,61 @@ Student ID: 3431709 1. Problem Statement: -```text -Create a Person class that includes the name of the person, -the weight of the person (in pounds), and the height of the person (in inches). -For the data listed in the table below, create four Person objects. -Compute their individual body mass index (BMI) and store it as part of these objects. + Create a `Person` class that includes the name of the person, + the weight of the person (in pounds), and the height of the person (in inches). + For the data listed in the table below, create four Person objects. + Compute their individual body mass index (BMI) and store it as part of these objects. -Further, determine their weight category and add that information as part of -the object as well. + Further, determine their weight category and add that information as part of + the object as well. -Store each of these four Person objects, their corresponding BMI, -and weight category in a different ArrayList and develop get and set methods -to access elements in that ArrayList. -``` + Store each of these four Person objects, their corresponding BMI, + and weight category in a different ArrayList and develop get and set methods + to access elements in that ArrayList. -| Name | Weight (pounds) | Height (inches) | -| ------------- |:---------------:| ---------------:| -| Andrew | 125.5 | 55.1 | -| Boyd | 150.0 | 67 | -| Cathy | 135 | 72.3 | -| Donna | 190 | 64 | + | Name | Weight (pounds) | Height (inches) | + | ------------- |:---------------:| ---------------:| + | Andrew | 125.5 | 55.1 | + | Boyd | 150.0 | 67 | + | Cathy | 135 | 72.3 | + | Donna | 190 | 64 | -BMI is calculated using the following formula: + BMI is calculated using the following formula: -```text -BMI = (weight (lb) * 703) / ((height (in))^2) -``` + BMI = (weight (lb) * 703) / ((height (in))^2) -BMI can indicate the following categories: + BMI can indicate the following categories: -* Underweight when BMI is less than 18.5 -* Normal weight when BMI is between 18.5 and 25 -* Overweight when BMI is between 25 and 30 -* Obese when BMI is 30 or greater + * Underweight when BMI is less than 18.5 + * Normal weight when BMI is between 18.5 and 25 + * Overweight when BMI is between 25 and 30 + * Obese when BMI is 30 or greater 1. Description of the Code: + + The code includes a single class called `Person`. + The `Person` class is constructed with a name, weight and height. + The weight and height is used to calculate the BMI for the person and attach a + category. + 1. Errors and Warnings: + + This program does not accept input from a user. + 1. Sample Input and Output: + + 1. An example run of the program. + + ```bash + java -cp target/assignment2*.jar ca.mokhan.comp268.App 7 + Name Weight Height BMI Category + ----------------------------------------------- + Andrew +125.5 +55.1 +29 Overweight + Boyd +150.0 +67.0 +23 Normal + Cathy +135.0 +72.3 +18 Underweight + Donna +190.0 +64.0 +33 Obese + ``` + 1. Discussion: + + BMI is not a useful measurement of health. |
