Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »
Lab week2
DPIT111 Assignment 5
Week 10-11

Objectives
• Get familiar with recursion
• Get familiar with a
ay
• Get familiar with A
ays class
• Get familiar with A
ayList

Assignment 5 (12%) is marked on a scale from 0-12 marks.

Important notices:
This assignment is scheduled to be done in Week XXXXXXXXXXMonday 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 e
or in your file
will result in 0 points for the cu
ent 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 a
ay
which is input by the user.

REQUIREMENTS
• The user input is always co
ect (input verification is not required).
• Your code must use recursion and a
ay.
• The recursion method int multiplication(int[] a
ay, int startIndex, int
endIndex) is a recursion one whose arguments are an positive integer a
ay and two integers, the
eturn value is an integer.
• The main method prompts the user to enter the number num of an a
ay first, and then to enter the
elements of the a
ay myA
ay, calculates the multiplication of all elements of the a
ay by calling
the method multiplication(myA
ay, 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 a
ay is: 6
The elements of your a
ay are: XXXXXXXXXX
The multiplication of {1, 2, 3, 4, 5, 6} is 720.

Example 2:
The length of your a
ay is: 5
The elements of your a
ay are: XXXXXXXXXX
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 a
ay with
A
ayList 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 A
ayList. The user input ends up with -1 and -1 is not counted as the
elements of A
ayList.
REQUIREMENTS
• The user input is always co
ect (input verification is not required).
• Your code must use recursion and A
ayList.
• The recursion method int multiplication(A
ayList al, int
startIndex, int endIndex)is a recursion one whose arguments are an positive integer
A
ayList and two integers, the return value is an integer.
• The main method prompts the user to enter the elements of the A
ayList myA
ayList,
calculates the multiplication of all elements of the a
ay by calling the method
multiplication(myA
ayList, 0, myA
ayList.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 a
ay are: XXXXXXXXXX
The multiplication of {1, 2, 3, 4, 5, 6} is 720.

Example 2:
The elements of your a
ay are: XXXXXXXXXX
The multiplication of {2, 5, 8, 12, 67} is 64320.


Question 3 (4 mark) : Build a new integer a
ay, all elements come from the user input. Then sort the a
ay
and display all elements in a descending order.

REQUIREMENTS
• The user input is always co
ect (input verification is not required).
• Your code must use the sort() method of A
ay 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
XXXXXXXXXX XXXXXXXXXX234
XXXXXXXXXX XXXXXXXXXX145
XXXXXXXXXX XXXXXXXXXX112
XXXXXXXXXX XXXXXXXXXX56
XXXXXXXXXX XXXXXXXXXX17
XXXXXXXXXX XXXXXXXXXX16
XXXXXXXXXX XXXXXXXXXX13
XXXXXXXXXX XXXXXXXXXX10
XXXXXXXXXX XXXXXXXXXX9
XXXXXXXXXX XXXXXXXXXX8
XXXXXXXXXX XXXXXXXXXX7
XXXXXXXXXX XXXXXXXXXX1
Example 2:
Please enter all numbers, separated by ",": 12,4,78,90,6
Sequence No. Descending Elements
XXXXXXXXXX XXXXXXXXXX90
XXXXXXXXXX XXXXXXXXXX78
XXXXXXXXXX XXXXXXXXXX12
XXXXXXXXXX XXXXXXXXXX6
XXXXXXXXXX XXXXXXXXXX4

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
esults are published. After 1 week the marks cannot be changed.

Mark deductions: late submission, compilation e
ors, inco
ect 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 Day Sep 18, 2021

Solution

Neha answered on Sep 19 2021
151 Votes
65708 - java code/A
ayListMultiply.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