Lab week2 DPIT111 Assignment 5 Week 10-11 Objectives • Get familiar with recursion • Get familiar with array • Get familiar with Arrays class • Get familiar with ArrayList Assignment 5 (12%) is marked...

1 answer below »
It's a assignment of programming just 3 Questions


Lab week2 DPIT111 Assignment 5 Week 10-11 Objectives • Get familiar with recursion • Get familiar with array • Get familiar with Arrays class • Get familiar with ArrayList Assignment 5 (12%) is marked on a scale from 0-12 marks. Important notices: This assignment is scheduled to be done in Week 10-11 (Monday 7 September - Saturday 19 September 19:00). Comments for your work can be checked on Moodle site. You may be asked questions about your code. Your marks will be deducted if you could not answer the questions presented by the assessor. 1. Students must submit all assessment tasks by the due date or penalties will be applied. No. of calendar days late Penalty 1 10% of the original mark. 2 20% of the original mark. 3 30% of the original mark. More than 3 A mark of zero will be awarded for the assessment. 2. Make sure that you include following personal information in every file, otherwise it will result in 0 points. /*------------------------------------------------------ My name: My subject code: My student number: My email address: Assignment number: -------------------------------------------------------*/ 3. Ensure each file in your submission is runnable, compiling error in your file will result in 0 points for the current question. If it is runnable, though it fails to realize all functionalities, you can get partial points for what you have done. Question 1 (4 mark) : Implement a program which computes the multiplication of all integers in an array which is input by the user. REQUIREMENTS • The user input is always correct (input verification is not required). • Your code must use recursion and array. • The recursion method int multiplication(int[] array, int startIndex, int endIndex) is a recursion one whose arguments are an positive integer array and two integers, the return value is an integer. • The main method prompts the user to enter the number num of an array first, and then to enter the elements of the array myArray, calculates the multiplication of all elements of the array by calling the method multiplication(myArray, 0, num - 1), displays the result as the following examples. • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: The length of your array is: 6 The elements of your array are: 1 2 3 4 5 6 The multiplication of {1, 2, 3, 4, 5, 6} is 720. Example 2: The length of your array is: 5 The elements of your array are: 2 5 8 12 67 The multiplication of {2, 5, 8, 12, 67} is 64320. Question 2 (4 mark) : Modify the above program to complete the same task by replacing the array with ArrayList so that the user does not need to specify the input length at first. The recursion method’s first argument should also be changed to ArrayList. The user input ends up with -1 and -1 is not counted as the elements of ArrayList. REQUIREMENTS • The user input is always correct (input verification is not required). • Your code must use recursion and ArrayList. • The recursion method int multiplication(ArrayList al, int startIndex, int endIndex)is a recursion one whose arguments are an positive integer ArrayList and two integers, the return value is an integer. • The main method prompts the user to enter the elements of the ArrayList myArrayList, calculates the multiplication of all elements of the array by calling the method multiplication(myArrayList, 0, myArrayList.size()-1), displays the result as the following examples. • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: The elements of your array are: 1 2 3 4 5 6 -1 The multiplication of {1, 2, 3, 4, 5, 6} is 720. Example 2: The elements of your array are: 2 5 8 12 67 -1 The multiplication of {2, 5, 8, 12, 67} is 64320. Question 3 (4 mark) : Build a new integer array, all elements come from the user input. Then sort the array and display all elements in a descending order. REQUIREMENTS • The user input is always correct (input verification is not required). • Your code must use the sort() method of Array class. • Your code must use the split() method to process the user input. • Your alignment must be exactly the same as the example. • Your code must work as the following example (the text in bold indicates the user input). Example of the program output: Example 1: Please enter all numbers, separated by ",": 1,234,56,7,8,9,10,112,13,145,16,17 Sequence No. Descending Elements 11 234 10 145 9 112 8 56 7 17 6 16 5 13 4 10 3 9 2 8 1 7 0 1 Example 2: Please enter all numbers, separated by ",": 12,4,78,90,6 Sequence No. Descending Elements 4 90 3 78 2 12 1 6 0 4 Submission requirements: 1. Put each solution into a text file (.txt), and submit them to the Assignment link. The submission link is called Assignment 5 Submission under Week 10 Section on the subject Moodle site. 2. Submission via email is not acceptable without permission. 3. Enquiries about the marks can only be made within a maximum of 1 week after the assignment results are published. After 1 week the marks cannot be changed. Mark deductions: late submission, compilation errors, incorrect result, program is not up to spec, poor comments, poor indentation, meaningless identifiers, required numeric constants are not defined, the program uses approaches which has not been covered in the lectures. The deductions here are merely a guide. Marks may also be deducted for other mistakes and poor practices. END OF THE ASSIGNMENT
Answered Same DaySep 18, 2021

Answer To: Lab week2 DPIT111 Assignment 5 Week 10-11 Objectives • Get familiar with recursion • Get familiar...

Neha answered on Sep 19 2021
148 Votes
65708 - java code/ArrayListMultiply.java
65708 - java...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here