Question: please solve all part usisng java. Assignment 2 Instructions: This assessment covers the contents discussed till Week 5 - All submitted assigned work must conform
please solve all part usisng java.



Assignment 2 Instructions: This assessment covers the contents discussed till Week 5 - All submitted assigned work must conform to proper Java programming style and documentation. Especially regarding naming conventions. - Your source code should contain comments describing the functionality and the major components of each object and method. - Student full name and student number MUST be included on each submitted work - The word file/ pdf is to be submitted in which you paste the screenshot of code and its output executed in VS Code - The file should have proper page borders and formatting. Student name, assignment name, ID number should be displayed on every page header. - All assigned work should be completed by the student without the collaboration of others. - Unauthorized collaboration will be treated as violations of academic integrity under the Sheridan's Academic Integrity Policy. - All assignment solutions should be uploaded to the appropriate Assignments folder - Professional/personal integrity is very important. Any noted cheating will be dealt accordingly with the Sheridan's policies. - For writing code, proper indentation, naming conventions are to be followed. Questions: Q1. (Locate the smallest element) Write the following method that returns the location of the smallest element in a two-dimensional array. public static int[] locateSma1lest(double [] [] a) The return value is a one-dimensional array that contains two elements. These two elements indicate the row and column indices of the smallest element in the two-dimensional array. Write a test program that prompts the user to enter a twodimensional array and displays the location of the smallest element in the array. Here is a sample run: Enter the number of rows and columns of the array: 34 Enter the array: The location of the smallest element is at (0,2) Q2. (Remove duplicates) Write a method that removes the duplicate elements from an array list of integers using the following header: public static void removeDuplicate(ArrayList 1ist) Write a test program that prompts the user to enter 10 integers to a list and displays the distinct integers in their input order and separated by exactly one space. Here is a sample run: Enter 10 integers: 345356433224IEnter The distinct integers are 345364332 Q3. (Algebra: perfect square) Write a program that prompts the user to enter an integer m and find the smallest integer n such that m " n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m=90, store the factors 2,3,3, and 5 in an array list. 2 and 5 appear an odd number of times in the array list. Thus, n is 10 .) Here are some sample runs: Enter an integer m:1500 The smallest number n for mn to be a perfect square is 15 m * n is 22500 Enter an integer m:63 The smallest number n for mn to be a perfect square is 7 mn is 441 Q4. (The Colorable interface) Design an interface named Colorable with a void method named howToColor (). Every class of a colorable object must implement the Colorable interface. Design a class named Square that extends Geometricobject and implements Colorable. Implement howToColor to display the message Color al1 four sides. The Square class contains a data field side with getter and setter methods, and a constructor for constructing a Square with a specified side. The Square class has a private double data field named side with its getter and setter methods. It has a no-arg constructor to create a Square with side 0, and another constructor that creates a Square with the specified side. Draw a UML diagram that involves Colorable, Square, and Geometricobject. Write a test program that creates an array of five Geometricobjects. For each object in the array, display its area and invoke its howToColor method if it is colorable. Rubrics (10 marks total): Originality and correctness 6 marks Proper Programming Style (indentationaming conventions/spacing etc.)- 4 marks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
