Requirements of this Lab
- Do not modify the JUnit test class given to you.
- For each utility method in the Utilities class that you are assigned to implement, as discussed in Part F of Week 1s Java tutorial videos:
- No out.println statements should appear in each of the utility method.
Instead, an explicit, final return statement is placed for you.
- No Scanner operations (e.g., nextInt()) should appear in each of the utility method.
Instead, refer to the input parameters of the method.
- To complete this lab, it is not necessary to use loops or methods from library classes (e.g., Math).
- You are welcome to ask questions related to this lab or the assigned tutorial videos on the forum. However, please be cautious:
- You can help your fellow students understand the requirements of tasks.
- Do not share the code you developed to ask, or to answer, questions.
Questions specific to the code you write would be best and most effectively addressed by TAs (during scheduled labs) or your instructor (during office hours or appointments).
Week 2s tutorial videos (Parts C to E) introduce to you debugger in Eclipse. You are encouraged to set breakpoints and launch the debugger when you are stuck at your own program.
- Hints on how the solution should look like are left only to the instructors who moderate the forum.
1 Task 1: Complete Weekly Java Tutorial Videos
- For Lab1, you are assigned to study Week 2 Part A to Part G of the Java tutorial series:
https://www.youtube.com/playlist?list=PL5dxAmCmjv_6wy2m0yq2wObIWPz4tAxW6
These Java tutorial videos assigned to you are meant for you to:
- Obtain extra hands-on programming experience on Java, supplementing your weekly lectures.
- Complete the lab assignment with the necessary skills and background.
Parts A to E are directly relevant to this lab. Parts F and G are relevant to your Lab2.
Though we do not require the submission of the weekly Java tutorial project (like in Lab0), examples and insights discussed in these tutorials will be covered in your (written and programming) tests and exam: should you decide to skip the weekly tutorial videos, it would be your choice.
As you study through the example Java classes in the tutorial videos, you are advised to type them out (but absolutely feel free to add new Java classes to experiment) on Eclipse.
- You can find the iPad notes of illustrations from the tutorial videos here:
https://www.eecs.yorku.ca/jackie/teaching/tutorials/notes/EECS1022%20Tutorial%20on%20Java.pdf
2 Task 2: Complete Programming Exercises
Starting Task 2 should mean that you have already completed the weekly Java tutorial videos (Section 1).
2.1 Step 1: Download and Import the Starter Project
- Download the Eclipse Java project archive file from eClass: zip
- Launch Eclipse and browse to EECS1022-W21-workspace as the Workspace then click on Launch, e.g.,
3.3 Choose Select archive file. Make sure that the EECS1022W21Lab1 box is checked under Projects.
2.2 Step 2: Programming Tasks
From the Package Explorer of Eclipse, your imported project has the following structure.
- You can manually test the assigned methods using the corresponding console application classes in package consoleapps. These classes are completed and given to you. See below for more descriptions.
- Your goal is to pass all JUnit tests given to you (i.e., a green bar). To run them, as shown in the Java tutorials on Week 1, right click on java and run it as JUnit tests. Of course, none of the given tests would pass to begin with.
2.2.1 Method to Implement: getGeometricSequence
Problem. You are asked to consider a geometric sequence (of integer values) of length 5.
ha1, a2, a3, a4, a5i
where a1, the start of the sequence, is called the first term. In a geometric sequence, there is a common ratio r between every two adjacent terms:
2 i 5
For example, h6, 12, 24, 48, 96i is a geometric sequence with 6 being the first term, 2 being the common ratio, and 5 being the length.
Testing. Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class GeometricSequenceApp if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run:
| Enter the first term of a geometric sequence (of size 5):3Enter the common ratio of the geometric sequence: 2[3][6][12][24][48] has average 18.6 |
Todo. Implement the Utilities.getGeometricSequence method. See the comments there for the input parameters and requirements. The String return value must conform to the expected format.
2.2.2 Method to Implement: getBMI
Problem. You are asked to compute the Body Mass Index (BMI), which is a measure of health based on height and weight specified in metric units (i.e., meters and kilograms, respectively). Given a user weighting k kilograms and who is m meter tall, their BMI is calculated as: (i.e., weight divided by the square of height). Once the BMI is calculated, one may consult with the following table to interpret the result:
BMI Range Interpretation
| BMI < 18.5 | Underweight |
| 18.5 BMI < 25.0 | Normal |
| 25.0 BMI < 30.0 | Overweight |
| 30.0 BMI | Obese |
For this exercise, you are only asked to compute the BMI without interpreting it as specified above. Users of your program, however, will specify a weight in pounds and a height in inches, meaning that you need to consider the following conversions:
- 1 pound is equivalent to 0.4536 kilograms
- 1 inch is equivalent to 0.0254 meters
Testing. Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class BMIApp if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run:
| Enter your name: JimJim, enter a non-negative floating-point number of your weight (in pounds): 223.5Jim, enter a non-negative floating-point number of your height (in inches):68.77Jim, your BMI is: 33.22653789251047 |
Todo. Implement the Utilities.getBMI method. See the comments there for the input parameters and requirements. The double return value needs no formatting, but it must be within a tolerance range of 0.1 against the expected value. You can also play with calculations using this web-based BMI calculator here: https://www.nhlbi.nih.gov/health/educational/lose_wt/BMI/bmicalc.htm
2.2.3 Method to Implement: getTimeConversion
Problem. You are asked to convert a given (non-negative) integer number of seconds and convert it into its equivalent formatted in terms of days, hours, minutes, and seconds.
Testing. Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class TimeConversionApp if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run:
Enter a non-negative integer number of seconds:
10000
0 days 2 hours 46 minutes 40 seconds
Todo. Implement the Utilities.getTimeConversion method. See the comments there for the input parameters and requirements. The String return value must conform to the expected format (e.g., words days, hours, minutes, and seconds are always in their plural form). Of course, in the output, the maximum values that can appear for hours, minutes, and seconds are, respectively, 23, 59, and 59.
2.3 Step 3: Exporting the Completed Project
You are required to submit a Java project archive file (.zip) consisting all subfolders.
- In Eclipse:
3.3 Check the top-level EECS1022W21Lab1
Make sure that all subfolders are checked: .settings, bin, and src.
Under To archive file: browse to, e.g., desktop, and save it as EECS1022W21Lab1.zip (case-sensitive)
Note. In case you have concerns about exporting and submitting the .setting subfolder: it will be kept confidential and access-protected on eClass.

![[Solved] EECS1022 Lab1-Elementary Programming (with no conditionals or loops)](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] EECS1022 Lab5-Single Class, Attributes, Methods, JUnit Tests](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.