0% found this document useful (0 votes)
17 views4 pages

Lab1A CLO2

Uploaded by

mudafuqer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Lab1A CLO2

Uploaded by

mudafuqer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EECS2030A: LAB 1 Due: Sept 11th, 2024 - 11:59 pm

Max. Marks: 100

The purpose of this lab is to:


A. Ensure that you have all the tools available for the rest of the term.
B. Write a simple code to practice automating the testing process.
C. Ensure that you know how to submit your programming assignments.
Although you can always use the Lassonde lab machine, even remotely, you can also
download an editor for your computer at home to write your Java code. In this course, we
use Eclipse, which is a professional editor for programming in many languages, including
Java. In case you already have Eclipse on your machine, or you are going to use Lassonde
lab’s machine, then you can skip step 1.

1. Eclipse
To download, click on the link below, where you can find the download links for different
operating systems:
https://www.eclipse.org/downloads/packages/release/luna/sr1/eclipse-ide-java-
developers
The installation is easy, as you only need to follow the instructions given by the installer. In
case you encounter any issues during the installation, please attend the lab and seek help
from the teaching assistants.
In addition, you can watch the following you-tube videos for installation (though it’s for older
versions of Eclipse, but the concept of installation is same):
a) Windows: https://www.youtube.com/watch?v=tJYCBXk_11k
b) Mac OS: https://www.youtube.com/watch?v=vOF35qsWn8M
Eclipse comes with the compiler and executor, so you don't need to install anything else.

2. Writing a simple code


Your instructions are clear, but I'll make a small adjustment for better readability:
A Java program should belong to a package, which in turn belongs to a project. Follow the
steps below to write a Java code:
1. Create a project by selecting File -> New -> Project.
2. Enter "EECS2030" as the project name.
3. Use an execution environment JRE – you can select the JavaSE-22 (anything above
JavaSE-14 is good)
4. Click Finish.

Page 1 | 4
EECS2030A: LAB 1 Due: Sept 11th, 2024 - 11:59 pm
Max. Marks: 100

The next step is to create a package.


1. Right-click on the EECS2030 project and select New -> Package.
2. Enter Lab1 and click Finish. Remember, by convention, the name of the package
should start with a lowercase letter.
Now, you are ready to write your program. Follow these steps:
1. Right-click on the Lab1 package and select New -> Class.
2. Enter Lab as the class name. Remember, by convention, the name of the class should
start with an uppercase letter.
3. Don’t select main method to be included as you are not writing main method in this
lab.
In this file and the class that is created, you need to write a few methods.

❖ The First Method


The method, called getMyID(), accepts no parameters and returns your student number. The
return type must be a string. Please ensure that you return the correct student number;
otherwise, we won't be able to calculate your grade. The method signature should look like
the one below:
public static String getMyID()

❖ The Second Method


This method accepts a double number, representing a grade, and returns the equivalent
letter grade. The letter grade is computed using the following table:
Grade Per Cent Range
A+ ≥ 90
A 80 ≤ < 90
B+ 75 ≤ < 80
B 70 ≤ < 75
C+ 65 ≤ < 70
C 60 ≤ < 65
D+ 55 ≤ < 60
D 50 ≤ < 55
E 45 ≤ < 50
F < 45
The name of the method is getLetterGrade() and the return type is a string. The method
signature is:
public static String getLetterGrade(double)
Page 2 | 4
EECS2030A: LAB 1 Due: Sept 11th, 2024 - 11:59 pm
Max. Marks: 100

❖ The Third Method


This method, called addAndChangeScale(), takes an ArrayList of grades and returns the total
of the grades at the scale of 10. All the grades in this ArrayList are out of 100. Let’s see a few
examples:
Input: {90, 95, 100}, Output: 9.50
Input: {92.5, 94, 100, 100, 90}, Output: 9.53
Please note that the output should be calculated and displayed with two decimal points. The
signature of the method is as follows:
public static double addAndChangeScale(ArrayList<Double>)
Important Note: It is extremely important that the identifiers that you choose for the class
and methods are the same as what is given in this description. Otherwise, our tester cannot
read your code, and you will lose the mark for this lab.

3. Testing your code


You should be able to use JUnit 4 to test your code. Although we don't want you to submit
your tester, we expect you to write your own tester as it is part of the objective of this lab.
Since we assume that you have tested your code using JUnit, your code should not contain
the main method.
When writing a tester, ensure that you have an (almost) comprehensive set of test cases. For
example, for the getLetterGrade() method, choose a test case that is representative of each
grade group (e.g., one test case when 90 < grade < 100, one test case when 80 < grade < 90,
and so on). Also, include a test case for each borderline value (e.g., 100, 90, 80, and so on). If
any of these does not make sense to you, please talk to the TA and ask them to explain it to
you.

4. Documentation
It's good practice to develop the habit of writing JavaDoc for your code. Java documentation
sits between /** and */. Try it for one of the methods and see how Eclipse inserts the names
of the inputs and return variables. Write a description for each variable so that the purpose
of the method is clear to the reader of the code. Also, please add a proper precondition to this
documentation as below:
@pre The input grade is a double number between zero and 100 inclusive.

Page 3 | 4
EECS2030A: LAB 1 Due: Sept 11th, 2024 - 11:59 pm
Max. Marks: 100

5. Submit
Submit only one file named "Lab.java" via eClass by clicking on the lab link.

6. Marking Schema
You are graded based on the correctness of your code. For each method, there will be a few
test cases to examine the correctness of the code. All test cases carry the same weight.
Please note that in all the labs, even if the test cases are provided, we will test your code with
a different set of test cases to ensure that you have tested your code completely.
Note:
▪ The program that does not compile will get zero marks
▪ No resubmissions are allowed. Therefore, please make sure you submit the correct
file within due date.
*******************************************************************************************

Page 4 | 4

You might also like