$29
You will earn total 100 points.
Note 1: This homework set is individual homework, not a team-based e ort. Discussion of the concept is encouraged, but actual write-up of the solutions must be done individually. Note 2: Turn in one yourLastName-yourFirstName-hw5.zip le on eCampus, nothing else. Your zip directory must include the two .java les (Fibonacci.java and Vehicle.java) with your implementations in them, and a README le that explains how to compile and execute your codes, and what is the expected output of your codes when tested. The README le is worth ten points.
Note 3: All Java code that you submit must compile without errors using javac of Java version 8 or higher (most recent version is version 14). If your code does not compile, you will likely receive zero points for this assignment.
Note 4: Remember to put the head comment in all of your les, including your name, your UIN, and acknowledgements of any help received in doing this assignment. Again, remem-ber the honor code.
Problem 1. (10 points) Explain in a readme le (just .txt le) how to compile and execute your codes, and what is the expected output of your codes when tested. It should be detailed enough so that whoever grades your codes can understand what you were doing with your code clearly and should be able to reproduce your tests following what you wrote in it.
Problem 2. (10 points) Section 1.6. Modify ImprovedFibonacci on pages 9{10 as in-structed below. Name your modi ed class SubsetOutputFib, and place it in a le named Fibonacci.java.
Let fn denote the n-th Fibonacci number. The SubsetOutputFib will accept two integer values as command line input, assign the rst one to be (meaning begin) and the second one to en (meaning end), and print out only those Fibonacci numbers from fbe to fen. For example, if the two command line arguments are given as 4 and 7 in this order, then the output should be:
4: 3
5: 5
6: 8 *
7: 13
1
Make sure that you do the error checking whether both be and en are positive integers, and be en.
Problem 3. (10 points) Section 1.10, Exercise 1.13 on page 24. Modify the ImprovedFibonacci on pages 9{10 (not the modi ed version in Problem 2). Place the modi ed ImprovedFibonacci implementation in the same le as Problem 2 (Fibonacci.java).
Problem 4. (20 points) Section 2.1, Exercise 2.1 on page 44, Section 2.2, Exercise 2.3 on page 46, and Section 2.6, Exercise 2.13 on page 68. Work in a le Vehicle.java.
Use the following types for the elds: int for current speed, int for current direction in degrees (consider straight north as 0 degrees and the degree increments clockwise up to 359 degrees, thus for example, straight east is 90 degrees, straight south 180 degrees, and straight west 270 degrees), and String for owner name.
For Exercise 2.3, use int for both of the vehicle ID number elds. The static eld for the next vehicle ID number should be simply incremented by one each time a vehicle instance is created.
Problem 5. (10 points) Section 2.4, Exercise 2.5 on page 50. Write the main method within a new class named VehicleTestP4. Create 5 vehicles and print their eld values. To do so, create the vehicles (using the default constructor since you have not implemented any constructor of your own yet), set the values using the accessor (setter) methods that you implemented in Exercise 2.13 in the previous problem, and use the getter methods to print their eld values.
Problem 6. (10 points) Section 2.5, Exercise 2.7 on page 54, and Section 2.6, Exercise 2.9 on page 58. You will continue working on your Vehicle class from Problem 4, but the modi ed main needs to be in a di erent class, named VehicleTest since in the new main, you will now create the ve vehicles using the constructor you added to the Vehicle class. Keep both VehicleTestP4 and VehicleTest in the same le Vehicle.java. From now on, whenever you add new functionalities to Vehicle, you will add the test code for the new functionalities in the main method of VehicleTest.
Problem 7. (10 points) Section 2.6, Exercise 2.10 on page 60. Add test code of your toString method in the main method of VehicleTest.
Problem 8. (10 points) Section 2.6, Exercise 2.15 on page 68. Add test code of those methods in the main method of VehicleTest.
Problem 9. (10 points) Section 2.8, Exercise 2.17 on page 71. Add test code of those methods in the main method of VehicleTest.
Have fun!
2