EECS1710 PRACTICE LABTEST (1A)

You have 80 minutes to complete this test. The test starts at the beginning of your scheduled lab and finishes 80 minutes later. You will have a 5-minute warning to submit your work.

To do the lab test, you will work within three windows:

This is a closed book test. You may only use the resources linked below.

Follow the instructions carefully!


RESOURCES


GETTING STARTED

  1. The lab test is contained in a Java archive file – a ZIP file. Click here to download the archive file (click "save").

  2. Start Eclipse. In the Workspace Launcher, select the default workspace; i.e., "eclipse-workspace".

  3. Import the lab test as an Eclipse project. (Click here to review the instructions for importing a Java project archive file.)

  4. All the files needed for this lab test should now appear in Eclipse.

  5. Open a terminal. Use this terminal throughout the test to submit your work.

  6. Copy and paste the following commands into the terminal and press ENTER:

    cd
    cd eclipse-workspace/ptest1A

  7. Type the ls command to verify that you are in the correct directory. You should see the source (.java) files for the lab test. If you do not see the lab test files, use the cd, ls, and pwd commands to navigate to the lab test workspace directory. Submit the source files NOW!

    To submit, copy and paste the following command into the terminal and press ENTER:

    submit 1710 ptest1A Question*.java

    You should see something like the following if submission occurred successfully:

    submitted:  Question1.java (61 bytes)
    submitted:  Question2.java (61 bytes)
    submitted:  Question3.java (61 bytes)
    All files successfully submitted. 
    

    Alternatively, you can use web submit: https://webapp.eecs.yorku.ca/submit/.

  8. During the test, please keep the terminal open and use it to submit regularly. Do this by simply clicking in the open terminal window, pressing the up arrow key (↑) to find your previous submit command, and hitting ENTER to re-submit.

    There will be a 5-minute warning near the end of the test. Please re-submit immediately when you get that warning!

    The lab machine will shutdown at the end of the alotted test time.

    ASIDE: To check the files submitted, copy and paste the following command into your terminal and hit ENTER:

    submit -l 1710 ptest1A 

  9. Proceed to do the following questions. Ensure your code follows the style conventions discussed in lectures. Your code should be readable, use proper indentation, have no magic numbers, etc.

    In Eclipse, use Source → Format or Ctrl+Shift+F to ensure your code is properly formatted.

    Begin by opening the corresponding QuestionX.java file in Eclipse. Your first step is to replace the XXXs in the comment lines with your name and student number. Then, complete the programming task as per the instructions below. As you complete each question, submit your solution. Remember, repeated submits just overwrite previous submissions. Be sure to submit regularly! Good luck.


Question 1 (10 marks)

In Question01.java, write a simple program (main method) that converts an integer number of hours, minutes and seconds (stored as variables), into a total equivalent time (in minutes), and a total equivalent time (in seconds). Remember that there are 60 minutes in an hour, and 60 seconds in a minute.

Setup your own variables, assign them sample values and ensure that your code follows all appropriate STYLE conventions discussed in lectures (i.e. so that it is readable, has no magic numbers, compiles). YOU DO NOT NEED TO GET INPUT FROM THE USER!!

Format your output so that the total equivalent time in minutes displays as a result to 5 decimal places, while the total equivalent time in seconds displays as a result rounded to the nearest integer (formatted as follows):

Example 1: hours=7, minutes=6, seconds=13 should give the following output:

---------------
Time Converter:
---------------
7 hr, 6 min, 13 sec = 426.21667 minutes = 25573 seconds

Example 2: hours=1, minutes=28, seconds=14 should give the following output:

---------------
Time Converter:
---------------
1 hr, 28 min, 14 sec = 88.23333 minutes = 5294 seconds


Question 2 (10 marks)

In Question02.java, write a simple program (main method) that calculates and outputs the area of a triangle using Heron's formula. In this scenario, assume that:

Setup your own variables, assign them sample values and ensure that your code follows all appropriate STYLE conventions discussed in lectures (i.e. so that it is readable, has no magic numbers, compiles). YOU DO NOT NEED TO GET INPUT FROM THE USER!!

Format your output so that the length of each side is displayed as an integer in metres ("m"), and the area is shown in both square metres ("sq. m") and square feet ("sq. ft"), to the nearest 2 decimal places.

Note: 1 square metre is equal to 10.7639 square feet.

Example 1: if we set A=7m, B=6m, C=8m the output should be:

=============
Heron's Area:
=============
The triangle (A=7m, B=6m, C=8m) has an area of 20.33 sq. m = 218.86 sq. ft

Example 2: if we set A=3m, B=6m, C=5m the output should now be:

=============
Heron's Area:
=============
The triangle (A=3m, B=6m, C=5m) has an area of 7.48 sq. m = 80.55 sq. ft


Question 3 (10 marks)

In Question03.java create and complete the method called isIsoceles(a,b,c) that accepts three integer arguments that represent the lengths of the sides of a triangle (a, b and c). The method returns true if the triangle is isoceles i.e. only 2 of the 3 sides are equal in length. The method returns false otherwise. The method also returns false if any of the sides have zero length.

Examples of calling isIsoceles(a,b,c) with resulting output are shown below:

Complete the method isIsoceles(a,b,c) in the Question03.java file
There are tests included which you can run from the main method to check your output.

SUBMISSION

To submit, copy and paste the following command into the terminal and press ENTER. If this does not work, you need to navigate to your project folder (using cd) before running the submit command.

submit 1710 ptest1A Question*.java
again, upload all files Question0*.java to web submit to ptest1A through the following link