Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5:14 Search Done ArrayUtil_Test (1 of 33) int[] arr7 = { 4, 3, 6, -2, -1, -4 }; arrayUtility.setIntArray(arr7); System.out.println(Test 7 min value:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

5:14 Search Done ArrayUtil_Test (1 of 33) int[] arr7 = { 4, 3, 6, -2, -1, -4 }; arrayUtility.setIntArray(arr7); System.out.println("Test 7 min value: " + validate(-4, arrayUtility.minValue())); System.out.println("Test 7 max value: " + validate(6, arrayUtility.maxValue())); System.out.println("Test || unique: + validate(5, arrayUtility.countUniqueIntegers())); System.out.println("- int[] arr8 = { 0, -1, 0 }; arrayUtility.setIntArray(arr8); System.out.println("Test 8 - min value: " + validate(-1, arrayUtility.minValue())); System.out.println("Test 8 max value: " + validate(0, arrayUtility.maxValue())); count System.out.println("Test 8 count || unique: + validate (2, arrayUtility.countUnique Integers())); System.out.println(". int[] arr9 = { 1, 2, -1, 40, 1, 40, 0, 0, -3, 2, 2, -2, -5, 0, 1, -4, -5 }; arrayUtility.setIntArray(arr9); System.out.println("Test 9 min value: " + validate(-5, arrayUtility.minValue())); System.out.println("Test 9 max value: II + validate(40, arrayUtility.maxValue())); System.out.println("Test 9 count unique: " + validate(9, arrayUtility.countUniqueIntegers())); System.out.println(" -"); '); := 5:14 Search Done value: " + validate(-5, arrayUtility.minValue())); ArrayUtil_Test (1 of 33) arrayUtility.setIntArray(arr9); System.out.println("Test 9 value: " + validate(40, arrayUtility.maxValue())); value: unique: " + arrayUtility.countUnique Integers())); System.out.println("Test 9 max System.out.println("- "); int[] arr10 = { 4, 5, 5, 4, 1, 5, -3, 4, -1, -2, -2, -2, -2, -2, -2, 1, 4, 5, -5 }; arrayUtility.setIntArray(arr10); System.out.println("Test 10 min II + validate(-5, System.out.println("Test 9 count alidate(9, arrayUtility.minValue())); value: " + validate(5, arrayUtility.maxValue())); } System.out.println("Test 10 System.out.println("Test 10 II unique: + validate(7, arrayUtility.countUnique Integers())); System.out.println(' } min } // DO NOT MODIFY validate METHOD private static String validate(int expected, int answer) { match expected: } if (answer != expected) { || return ("The result " + answer + does not match expected: + expected + >> Failed"); II || } else { max count return ("The result " + answer + " II + expected + --->> OK"); := 5:13 Search Done unique: " + validate(5, arrayUtility.countUniqueIntegers())); ArrayUtil_Test (1 of 33) II System.out.pilnam TESL "); System.out.println(". int[] arr4 = { 8, 7, -1, -2, 9, 0, 3, 2, -2, 3, -2, 9, 2, -3, 3 }; arrayUtility.setIntArray(arr4); System.out.println("Test 4 min value: + validate(-3, arrayUtility.minValue())); value: " + validate(9, arrayUtility.maxValue())); 9, 10 }; System.out.println("Test 4 II unique: " + validate(9, arrayUtility.countUniqueIntegers())); System.out.println(" System.out.println("Test 4 count value: + validate(1, arrayUtility.minValue())); ."); int[] arr5 = { 1, 2, 3, 4, 5, 6, 7, 8, arrayUtility.setIntArray(arr5); System.out.println("Test 5 min value: " + validate(10, arrayUtility.maxValue())); System.out.println("Test 5 max unique: " + validate(10, arrayUtility.countUniqueIntegers())); System.out.println(" int[] arr6 System.out.println("Test 5 count = max value: || + validate(-3, arrayUtility.minValue())); "); { 2, -3, -1, 0, 1, -2 }; arrayUtility.setIntArray(arr6); System.out.println("Test 6 min value: " + validate(2, arravUtilitv.maxValue())): System.out.println("Test 6 max := 5:13 Search Done ArrayUtil_Test (1 of 33) arrayutiility.maxvalue())); System.out.println("Test 1 count unique: " + validate(5, arrayUtility.countUniqueIntegers())); System.out.println(" "); int[] arr2 = { 4, 3, -1, 1, -3, -1, 1, arrayUtility.setIntArray(arr2); System.out.println("Test 2 - min -5, -3, -4 }; value: " + validate(-5, arrayUtility.minValue())); System.out.println("Test 2 value: " + validate(4, arrayUtility.maxValue())); value: || unique: + validate (7, arrayUtility.countUniqueIntegers())); System.out.println("Test 2 count System.out.println("- 1, 1, 2 }; "); int[] arr3 = { 0, 0, 0, -3, 0, -1, -3, arrayUtility.setIntArray(arr3); System.out.println("Test 3 min II + validate(-3, arrayUtility.minValue())); System.out.println("Test 3 value: " + validate(2, arrayUtility.maxValue())); System.out.println("- unique: " + validate(5, arrayUtility.countUniqueIntegers())); max System.out.println("Test 3 count 2, -2, 3, -2, 9, 2, -3, 3 }; value: " + validate(-3, arrayUtility.minValue())); max int[] arr4 { 8, 7, -1, -2, 9, 0, 3, arrayUtility.setIntArray(arr4); System.out.println("Test 4 min System out println("Test / - may := 5:13 Search Done ArrayUtil_Test (1 of 33) vallale (4, arrayUtility.maxValue())); value: unique: " + validate(5, arrayUtility.countUnique Integers())); + System.out.println(" int[] arr2 System.out.println("Test 1 count -5, -3, -4 }; value: || arrayUtility.setIntArray(arr2); System.out.println("Test 2 min + validate(-5, arrayUtility.minValue())); II = value: + validate(4, arrayUtility.maxValue())); System.out.println("Test 2 max || _"); { 4, 3, -1, 1, -3, -1, 1, System.out.println("Test 2 count unique: " + validate(7, arrayUtility.countUniqueIntegers())); System.out.println(' int[] arr3 1, 1, 2 }; = '); { 0, 0, 0, -3, 0, -1, -3, arrayUtility.setIntArray(arr3); System.out.println("Test 3 min value: + validate(-3, arrayUtility.minValue())); System.out.println("Test 3 max value: " + validate(2, arrayUtility.maxValue())); System.out.println("Test 3 count unique: " + validate(5, arrayUtility.countUniqueIntegers())); "); = { 8, 7, -1, -2, 9, 0, 3, System.out.println(". int[] arr4 2, -2, 3, -2, 9, 2, -3, 3 }; arrayUtility.setIntArray(arr4); System.out.println("Test 4 value: " + validate(-3, arravlltility minValue())). min := 3:21 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... Test 9 count unique: The result 9 match expected: 9 --->> OK Test 10 min value: The result -5 match expected: -5 --->> OK Test 10 max value: The result 5 match expected: 5 -->> OK Test 10 count unique: The result 7 match expected: 7 --->> OK If a specific call fails that means that the returned value did not match the correct (expected) value. Looking at the example that failed will help you understand what went wrong in order to fix this. For example, this indicates the method for finding the minimum value did not pass the first test case (Test 0) we have. Test 0 min value: The result does not match expected: 1 --->> Failed Remember that the test cases are just samples used to check if your code works. You should expect that your code will be tested using other input values. Coding Style - (3 points) As we mentioned in class, formatting your code makes a difference when someone else has to look at it and review it. It is important to practice good formatting habits. Here are some guidelines to follow: o Appropriate variable names. In general, Submit Assignment Previous Dashboard 1000 Calendar 4 To Do Notifications Next Inbox 54 5:13 Search Done || value: + validate(2, arrayUtility.maxValue())); ArrayUtil_Test (1 of 33) System.out.println("Test 6 max unique: " + validate(6, arrayUtility.countUniqueIntegers())); value: II System.out.println("Test 6 count System.out.println(' '); int[] arr7 = { 4, 3, 6, -2, -1, -4 }; arrayUtility.setIntArray(arr7); System.out.println("Test 7 - min value: II + validate(-4, arrayUtility.minValue())); value: || || arrayUtility.maxValue())); System.out.println("Test 7 max + validate(6, || unique: " + validate (5, arrayUtility.countUniqueIntegers())); System.out.println("Test 7 count System.out.println(" int[] arr8 { 0, -1, 0 }; arrayUtility.setIntArray(arr8); System.out.println("Test 8 min + validate(-1, = arrayUtility.minValue())); System.out.println("Test 8 max value: + validate(0, arrayUtility.maxValue())); System.out.println("Test 8 count unique: " + validate(2, arrayUtility.countUnique Integers())); System.out.println(" int[] arr9 0, -3, 2, 2, -2, -5, 0, 1, -4, -5 }; ."); = { 1, 2, -1, 40, 1, 40, 0, arrayUtility.setIntArray(arr9); System.out.println("Test 9 - min "); value: " + validate(-5, arrayUtility.minValue())); := 3:21 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... Part A - Develop the algorithms (9 points) The challenge in the project is developing algorithms that accomplish basic operations over an array of integer numbers. The three operations are: Find the minimum (smallest) value that appears in the array Find the maximum (largest) value that appears in the array Determine the number of unique values that appear in the array Develop an algorithm for each of those tasks. The algorithms should work for any size of an array. If the array is empty (i.e., doesn't include any elements/values) the algorithm should output a zero. Keep in mind that like any computational problem there are several approaches to achieve a solution. For this programming checkpoint, your will need to utilize loops and conditional statements. Write the pseudocode or flowchart for the algorithm and store it in a filo (file format can be Previous Dashboard Submit Assignment 1000 Calendar 4 To Do Notifications Next Inbox 54 3:21 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... Submission Requirements (2 points) 1. Submit the pseudocode/flowchart file (named arrayUtilSteps) you developed in Part A. 2. Submit the code file for part B (ArrayUtil). 3. Submit a PDF document with the name project4Info.pdf that includes the following assignment information: 1. List of references used to acquire information, if any. 2. Explanation of any special or additional features you added, if any. 3. Explanation of status, stopping point, and issues if incomplete. 4. Discuss the easy and challenging parts of the assignment. How did you overcome all or some of the Dashboard challenges? 5. Did you learn anything that will help you perform better on future assignments? 6. If you completed any bonuses, include the documentation described in the Bonus section. If you updated the test program include that as well. Previous Submit Assignment 1000 Calendar 4 To Do Notifications Next Inbox 54 3:21 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... Write the pseudocode or flowchart for the algorithm and store it in a file (file format can be text, pdf, or doc) with the name arrayUtilSteps. Part B - Implement the class (21 points) The goal for this part is to implement a class with the algorithms developed in Part A. Create a class with the following requirements: 1. Class name is ArrayUtil 2. Has an integer array field named intArray 3. A default constructor 4. A constructor that accepts one argument for the array field and assigns that argument to the appropriate field (Here, the argument is an array passed by the driver class, ArrayUtil class will store it in its field ). You may assume that only valid values will be used to test the constructor ((i.e., you don't have to worry about input validation). 5. An accessor for the field. 6. A mutator for the field. 7. A method called minValue that does not accept any arguments and finds the minimum (smallest) value in the integer array and returns that value. Submit Assignment Previous Dashboard 1000 Calendar 4 To Do Notifications Next Inbox 54 3:21 NOTE: Remember to follow the Java naming conventions and the rules for encapsulation. Keep in mind that the algorithms for each of the methods should work for any size of array. If the array is empty (i.e., doesn't include any elements/values) they should return zero. You can test your code by running the ArrayUtil_Test program. The main method includes creating an object of your ArrayUtil class and several calls (tests) to each of the operations methods with varying arrays (length and content). If your logic is correct your output should look like this: Array Utility Project Test 0 min value: The result 0 match expected: 0 -->> OK Test max value: The result match expected: 0 -->> OK Test count unique: The result Test 1 Test 1 Test 1 Test 2 Test 2 Test 2 Test 3 Test 3 Test 3 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... Test 4 Test 4 Test 4 Test 5 Test 5 Test 5 Test 6 Test 6 Test 6 Test 7 Test 7 Test 7 min value: The result -3 max value: The result 4 count unique: The result min value: The result -5 match expected: -5 --->> OK max value: The result 4 match expected: 4 -->> OK count unique: The result 7 match expected: 7 --->> OK min value: The result -3 match expected: -3 --->> OK max value: The result 2 match expected: 2 --->> OK count unique: The result 5 match expected: 5 --->> OK match expected: 0 --->> OK match expected: -3 --->> OK match expected: 4 -->> OK 5 match expected: 5 --->> OK min value: The result -3 match expected: -3 --->> OK max value: The result 9 match expected: 9 -->> OK count unique: The result 9 match expected: 9 --->> OK min value: The result 1 match expected: 1 --->> OK max value: The result 10 match expected: 10 --->> OK count ique: esult 10 match expected: 10 --->> OK min value: The result -3 match expected: -3 --->> OK max value: The result 2 match expected: 2 --->> OK count unique: The result 6 match expected: 6 --->> OK Previous min value: The result -4 match expected: -4 --->> OK max value: The result 6 match expected: 6 --->> OK count unique: The result 5 match expected: 5 --->> OK Dashboard 1000 Submit Assignment Calendar 4 To Do Notifications Next Inbox 54 5:13 Search Done ArrayUtil_Test (1 of 33) /** * ITSC 1212 ArrayUtil_Test class for Project 4 */ public class ArrayUtil_Test { public static void main(String[] args) { // statements for output formatting System.out.println( *****"); Project *****"); System.out.println(" System.out.println("> ArrayUtil(); "); ArrayUtil arrayUtility int[] arr0 = {}; arrayUtility.setIntArray(arr0); System.out.println("Test 0 min value: " + validate(0, arrayUtility.minValue())); value: " + validate(0, arrayUtility.maxValue())); || System.out.println("Test 0 max System.out.println("Test 0 count unique: " + validate(0, arrayUtility.countUniqueIntegers())); System.out.println(' 3, 4, 0 }; Array Utility = new ); int[] arr1 = { 3, -3, -1, 0, -1, 4, 0 I arrayUtility.setIntArray(arr1); System.out.println("Test 1 min || value: + validate(-3, arrayUtility.minValue())); value: II + validate(4, arravlltility maxValue())) System.out.println("Test 1 max := 3:21 202210-Spring Description ITSC 1212 Project 3 Array Utility In this activity, we will be working on solving a specific problem using your knowledge of nested loops, arrays, and if-else statements. Code Provided Assignment Details 2022-ITSC-1212-201:ITSC-1212-202... You have been provided with a Java file: ArrayUtil_Test.java - The main function of this file is to test the class and methods you will create for this assignment. It includes a main method with several tests and a helper method to format the display of the result of the test. You do not need to modify anything in this file. Download and copy it into your project folder in VSCode. There will be errors at first but they'll go away as you complete the project. Part A - Develop the algorithms (9 points) The challenge in the project is developing Submit Assignment Previous Dashboard 1000 Calendar 4 To Do Notifications Next Inbox 54 3:21 Assignment Details 202210-Spring 2022-ITSC-1212-201:ITSC-1212-202... 8. A method called maxValue that does not accept any arguments and finds the maximum (largest) value in the integer array and returns that value. 9. A method called countUniqueIntegers that does not accept any arguments and determines the number of unique values that appear in the array and returns that value. (i.e., count of the number of unique groups of integer values in an array). For example, given this array of integers {1,2,2,4,3,5,4,3,8,10} we have 7 unique groups of values 1, 2, 3, 4,5, 8, 10. NOTE: Remember to follow the Java naming conventions and the rules for encapsulation. Keep in mind that the algorithms for each of the methods should work for any size of array. If the array is empty (i.e., doesn't include any elements/values) they should return zero. You can test your code by running the ArrayUtil_Test program. The main method includes creating an object of your ArrayUtil class and several calls (tests) to each of the operations methods with varying arrays (length and content). If your logic is correct your output should look like Submit Assignment Previous Dashboard 1000 Calendar 4 To Do Notifications Next Inbox 54 5:13 Search Done 9, 10 }; value: ArrayUtil_Test (1 of 33) int[] arr5 = { 1, 2, 3, 4, 5, 6, 7, 8, arrayUtility.setIntArray(arr5); System.out.println("Test 5 min + validate(1, arrayUtility.minValue())); System.out.println("Test 5 max value: " + validate(10, arrayUtility.maxValue())); System.out.println("Test 5 count unique: " + validate(10, arrayUtility.countUniqueIntegers())); value: System.out.println(". ."); int[] arr6 = { 2, -3, -1, 0, 1, -2 }; arrayUtility.setIntArray(arr6); System.out.println("Test 6 min value: " + validate(-3, arrayUtility.minValue())); System.out.println("Test 6 max + validate (2, arrayUtility.maxValue())); System.out.println("Test 6 count unique: " + validate(6, arrayUtility.countUniqueIntegers())); System.out.println(". int[] arr7 = -"); { 4, 3, 6, -2, -1, -4 }; arrayUtility.setIntArray(arr7); System.out.println("Test 7 min value: " + validate(-4, arrayUtility.minValue())); System.out.println("Test 7 value: " + validate(6, arrayUtility.maxValue())); - System.out.println(" System.out.println("Test 7 count unique: " + validate(5, arrayUtility.countUniqueIntegers())); max ."); :=

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Analytics Methods Models And Decisions

Authors: James R. Evans

2nd Edition

321997824, 978-1119298588, 978-0321997821

More Books

Students also viewed these Programming questions