Professional Documents
Culture Documents
Practical 4 102 2019
Practical 4 102 2019
50 + 25 = 75 MARKS
Deadlines
You must complete and submit your solutions up to and including Task 4 by 5pm on the day of
your practical. Instructions for how to submit your work are given in each section. Work that is not
submitted by this deadline will not be marked.
All remaining questions must be completed and submitted by 2pm on the Monday after the practical.
You only need to submit the .java file for each task on RUConnected.
The main should prompt the user to enter a sentence and the word that needs to be changed. For
Example:
Example 1:
Please enter a sentence: I can bend a tin.
Which word would you like to change: can
Bad case: I CAN bend a tin.
Example 2:
Please enter a sentence: I CAN bend a tin.
Which word would you like to change: can
For example:
Please enter the first word: dusty
Please enter the second word: study
dusty and study are anagrams
Task 3: Arr(ay) me Matey [25 marks]
Download the skeleton called ArrMateySkel.java. Complete the Java program so that it will do
the following:
● Read in an array of integers from the command line.
● Write a method that will:
○ Find the smallest number entered
○ Find the largest number entered
○ Find the sum of the numbers entered
● Write a method that will calculate the square of each value in the array.
● Write a method that will find the difference between neighbouring values in the array.
● Write a method that will find the absolute difference between the squares of neighbouring
values in the array.
Your program should display the following:
For example:
java ArrMatey -5 -10 0 5 10 15
The original array was: -5 -10 0 5 10 15
The min value is: -10
The max value is: 15
The sum of the values is: 15
The squares of each element is: 25 100 0 25 100 225
The differences are: 5 -10 -5 -5 -5
The abs differences of the squares are: 75 100 25 75 125
For example:
java FirstAlpha sat cart hat
cart
Code Submission: In order for your tutor to mark your program, you need to upload it to
RUConnected using the submission link. If you do not submit your code on RUConnected your tutor
can not mark it and you will get zero for this question.
For example:
java Anagram
Please enter the first word: Eleven plus two!
Please enter the second word: Twelve plus one?
Eleven plus two! and Twelve plus one? are anagrams
For example:
java FirstAlpha SAT Cart hat
Cart
Code Submission: In order for your tutor to mark your program, you need to upload it to
RUConnected using the submission link. If you do not submit your code on RUConnected your tutor
can not mark it and you will get zero for this question.