EECS 1022 Lab 1 Elementary Programming (with no conditionals or loops) solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

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:

These Java tutorial videos assigned to you are meant for you to:
1. Obtain extra hands-on programming experience on Java, supplementing your weekly lectures.
2. 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
4
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
1. Download the Eclipse Java project archive file from eClass: EECS1022 W21 Lab1.zip
2. Launch Eclipse and browse to EECS1022-W21-workspace as the Workspace then click on Launch, e.g.,
3. In Eclipse:
3.1 Choose File, then Import. 3.2 Under General, choose Existing Projects into Workspace.
3.3 Choose Select archive file. Make sure that the EECS1022 W21 Lab1 box is checked under Projects.
Then Finish.
5
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
console apps. 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 TestUtilities.java and run it as JUnit tests. Of course, none of the
given tests would pass to begin with.
You must not modify these given JUnit tests.
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:
ai
ai−1
= d 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):
3
Enter 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.
6
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: BMI =
k
m2 (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:
Jim
Jim, enter a non-negative floating-point number of your weight (in pounds):
223.5
Jim, enter a non-negative floating-point number of your height (in inches):
68.77
Jim, 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.
7
2.3 Step 3: Exporting the Completed Project
You are required to submit a Java project archive file (.zip) consisting all subfolders.
1. In Eclipse:
3.1 Right click on project EECS1022 W21 Lab1. 3.2 Under General, choose Archive File.
Then click Export
3.3 Check the top-level EECS1022 W21 Lab1
Make sure that all subfolders are checked: .settings, bin, and src.
Under To archive file: browse to, e.g., desktop, and save it as EECS1022 W21 Lab1.zip (case-sensitive)
Then Finish.
Note. In case you have concerns about exporting and submitting the .setting subfolder: it will be kept
confidential and access-protected on eClass.
8
3 Submission
1. Before you submit, you must make sure that the Problems panel on your Eclipse shows no errors (warnings
are acceptable). In case you do not see the Problems panel: click on Window, then Show View, then Problems.
Submitting programs with errors (meaning that it cannot be run for grading) will result in
possible partial, but low, marks.
2. Section 2.3 asks you to export the Java project as an archive file:
EECS1022 W21 Lab1.zip
Before you submit, verify that its unzipped version has the following structure:
Figure 1: Lab1 Expected Project Structure
3. Go to the eClass site for Sections M,N,O: https://eclass.yorku.ca/eclass/course/view.php?id=6214
4. Under the Lab Submissions section, click on Lab1 to submit the Java archive file: EECS1022 W21 Lab1.zip
• You may upload as many draft versions as you like before the deadline.
• You must explicitly submit the draft version for grading before the deadline.
• Once you click on the submit button, you can no longer upload another draft version.
9
4 Amendments
Clarifications or corrections will be added to this section.

10