Lab Quiz 3



Home | Resources | Homeworks | Exams | Slides | Labs | Contacts | Submit | Forums

Pledged lab quiz

 

Advice

 

The LabQuiz3 class

Complete and submit program LabQuiz3.java (right click on the link, select "save as...", then save the file to your home directory).  This class contains a single instance variable (named, conveniently, array), which is an int array.  The class will contain a number of methods to manipulate that int array.  Your task is to complete the following methods.  It is recommended that you first get the constructor working, followed by toString(), followed by the rest of the methods in this class.

 

Sample Output

Once working, your code should produce the following output.  The provided main() method helps the testing of your code.

Testing LabQuiz3(): the next line should be 20 0's
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]
        (this also requires toString() to work properly for it to display correctly)
Testing setValue(): the next line should be the squares of 1 to 15, followed by 5 0's
        [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 0, 0, 0, 0, 0, ]
        (this also requires toString() to work properly for it to display correctly)
Testing getValue(): should be 36: 36
Testing getValue(): should be 0: 0
Testing search(): should be 4: 4
Testing search(): should be -1: -1
Testing search(): should be 15: 15

 

Submission

Submit LabQuiz3.java here.

 

If you finish early...

Please take some time to do lab 12 if you finish early.