EECS1710 PRACTICE LABTEST

You have 80 minutes to complete this test.
This is a closed book test (you may use resources linked below).

Follow the instructions below carefully!!

The test will begin at 11.30am and will end at 12:50pm (you will have a 5 minute warning to submit your work)


RESOURCES


GETTING STARTED

  1. Start eclipse: click Activities, and click the last icon (left margin). In the search box, type "eclipse" and launch by clicking on the eclipse icon. Open eclipse in the default workspace! (i.e. "eclipse-workspace")

  2. Download this project file (save to Downloads folder).

  3. Import the test project by doing the following:

  4. All of the files you need for this test should now appear in eclipse.

  5. Open a terminal. You will use this terminal to submit your work.

  6. Copy and paste the following command into the terminal and press enter:
    cd
    cd eclipse-workspace/labtest

  7. You will see several java files. Please attempt a submit on these files NOW!
    To do this, copy and paste the following command into the terminal and press enter:
    submit 1710 lab5 Question*.java

    You should see the following message if submission occurred successfully:
    
    submitted:  Question1.java (61 bytes)
    submitted:  Question2.java (61 bytes)
    submitted:  Question3.java (61 bytes)
    All files successfully submitted.
     
    
    During the test, please keep this terminal open, and use it to submit regularly. Do this by simply clicking into the open terminal window, press the up arrow key to find your previous submit command, and hit enter to re-submit.

    There will be a 5 min 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 that have been submitted, you may copy and paste the following command to your terminal and hit enter.
    submit -l 1710 lab5 


QUESTIONS

For each of the following questions, open the corresponding QuestionX.java file in Eclipse, and complete the program/method(s) as per the given instructions below. As you complete each, do a submit (remember repeated submits will just overwrite older submissions - be sure to submit regularly)


Question 1 - Basics (10 marks)

In Question01.java, write a simple program (main method) that determines the total cash value held in a piggy bank jar full of small Canadian coins. The jar may contain only three types of coin within: nickels (worth 5 cents), dimes (worth 10 cents), and quarters (worth 25 cents).

Setup your own variables, assign them values and ensure that your code so 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 it displays the result in the following way:

Example 1: nickels=10, dimes=4, quarters=62 would give the following output:

nickels	   dimes      quarters   total
========== ========== ========== ==========
10         4          62         $16.40

Example 2: nickels=150, dimes=456, quarters=380 would give the following output:

nickels	   dimes      quarters   total
========== ========== ========== ==========
150        456        380        $148.10

Example 3: nickels=150, dimes=456, quarters=380 would give the following output:

nickels	   dimes      quarters   total
========== ========== ========== ==========
3055       5809       6670       $2401.15


Question 2 - Conditional Logic (10 marks)

In Question2.java complete a simple static method love6(a, b) that, given two integer values (a and b), will return true if either input (a or b) is 6, or their sum or difference is 6. Otherwise, it returns false

Note: the function Math.abs(num) computes the absolute value of a number (and may be used)

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

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

Question 3 - Loops (10 marks)

In Question03.java, complete the static method stringSplosion(str) that takes the String str as an input, and returns a new String as its result (formatted according to the following):

The returned String should be made up of several substrings joined together, each created from the input by progressively including the first 1,2,3, ... up to N characters of the original string str. Where N is the length of str.

For example, given a non-empty string like "Code" return a string like "CCoCodCode":

Other example input/outputs include:

Hint: you will likely need to use the substring method from java.lang.String
Again, there are tests included which you can run from the main method to check your output


SUBMISSION

To submit, again, copy and paste the following into the terminal window you opened earlier, and hit enter:

submit 1710 lab5 Question*.java