Question

Create a class fully-qualified as edu.udc.cs 1. ArrayWork. This class should have a static method that takes an integer array

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

Note: Since I don't have GUIUtils class mentioned, or any dependent classes, I cannot include any output.

//ArrayWork.java

package edu.udc.cs1;

public class ArrayWork {
        // required method
        public static double[] normalize(int[] array) {
                // creating a double array of same size
                double[] result = new double[array.length];
                // finding max value in array
                int max = array[0]; // initially assuming first element is the max
                // looping through rest of the elements, if any value > max, setting it
                // as the max
                for (int i = 1; i < array.length; i++) {
                        if (array[i] > max) {
                                max = array[i];
                        }
                }
                // now we loop through the array once again
                for (int i = 0; i < array.length; i++) {
                        // dividing element at index i in array by max value, storing result
                        // in result array at index i.
                        result[i] = (double) array[i] / max;
                }
                // finally returning result array
                return result;
        }
}
Add a comment
Know the answer?
Add Answer to:
Create a class fully-qualified as edu.udc.cs 1. ArrayWork. This class should have a static method that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • public class SimpleSoftmax {    /**    * This method calculates the softmax output of a...

    public class SimpleSoftmax {    /**    * This method calculates the softmax output of a non-normalized array.    * Example: double[] nonNormArr = {-3.0, 0.2, 7.8}    * gives the result {0.00002, 0.00050, 0.99948}    * Details of how to compute the softmax output can be found at zyBook instructions.    * Hint: use Math.exp(double a) to calculate the exponential values.    * @param nonNormArr The non-normalized array to be softmaxed. * @return The softmax output of the input...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? 3. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two...

  • Create another Java class named EmployeeMain within the same project, which includes the main method. a....

    Create another Java class named EmployeeMain within the same project, which includes the main method. a. Include another class named Employee in the same Java file. This class has the following instance variables and instance methods. Define all the instance/static variables with private access modifier and constructors, instance/static methods with public access modifier. Instance Variables empID: int employeeName: String basicSalary: double Constructor Set the value for empID. Instance Methods Get and set methods for all instance variables. displayEmployee: Display the...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...

  • * The Map class is used to create and manipulate voting maps. The value of a...

    * The Map class is used to create and manipulate voting maps. The value of a * cell on the map denotes the party for which the majority of the population * of that cell votes for. For instance, in the following map, PARTY_X is the * choice of voters in three cells, while PARTY_O is preferred in the rest of * the map: * O X O * X O X * O O O * A map is...

  • This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This...

    This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables:  An array of integers  A count of the number of elements currently in the array The class will have...

  • pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the...

    pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the last assignment by providing the following additional features: (The additional features are listed in bold below) Class Statistics In the class Statistics, create the following static methods (in addition to the instance methods already provided). • A public static method for computing sorted data. • A public static method for computing min value. • A public static method for computing max value. • A...

  • 1. Consider the class Circle below. Add an equals method to this class. The method should...

    1. Consider the class Circle below. Add an equals method to this class. The method should accept a Circle object as an argument. It should return true if the argument object contains the same data as the calling object, and false otherwise. public class Circle {     private double radius;     public Circle(double r)     {         radius = r;     }     public double getArea()     {         return Math.PI * radius * radius;     }     public double...

  • Course Class Create a class called Course. It will not have a main method; it is...

    Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A 4-letter abbreviation for the course (e.g., ITEC, PHED, CHEM) number A 4-digit number associated...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT