Given the following construct a UML diagram for Java:
Design a class named location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximum value and its indices in a two-dimensional array with row and column as int types and maxValue as double type.
Write the following method that returns the location of the largest element in two-dimensional array:
Public static Location locateLargest(double[][] a)
That return value is an instance of Location.
HI, Please find my implementation.
Please let me knwo in case of any issue.
public class Location {
// instance variables
private int row, column;
private double maxValue;
// constructor
public Location(int r, int c, double max) {
row = r;
column = c;
maxValue = max;
}
// getters and setters
public int getRow() {
return row;
}
public int getColumn() {
return column;
}
public double getMaxValue() {
return maxValue;
}
public void setRow(int row) {
this.row = row;
}
public void setColumn(int column) {
this.column = column;
}
public void setMaxValue(double maxValue) {
this.maxValue = maxValue;
}
// Method
public static Location locateLargest(double[][] a){
int r=0, c=0;
double max = a[0][0];
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
if(a[i][i] > max){
r = i;
c = j;
max = a[i][j];
}
}
}
return new Location(r, c, max);
}
}
Given the following construct a UML diagram for Java: Design a class named location for locating...
I need assistance writing the following Java class. Design a class named Location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type. Write the following method that returns the location of the largest element in a two-dimensional array: public static Location locateLargest(double[][]...
this language is JAVA
2. Design a class named Location for locating a maximum value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type. Write the following method that returns the location of the largest element in a two-dimensional array: Public static Location locateLargest(double [][] a) Create...
Assignment: Write a program with each of the following methods. You can assume this program is saved in a file called multiArrays.java. A sample main method and sample output is provided at the end of this section. All arrays created are of integer-type. Write a method to declare, initialize, and populate a two-dimensional array. Using the following header: public static int[ ][ ] declare2D(Scanner scnr) The user will indicate the size of the array. Write a method to declare,...
Draw a UML class diagram (with associations) to show the design of the Java application. public class OOPExercises { public static void main(String[] args) { //A objA = new A(); B objB = new B(); System.out.println("in main(): "); //System.out.println("objA.a = "+objA.getA()); System.out.println("objB.b = "+objB.getB()); //objA.setA (222); objB.setB (333.33); //System.out.println("objA.a = "+objA.getA()); System.out.println("objB.b = "+objB.getB()); } } public class A { int a = 100; public A() {...
Java Programming Assignment
Write a class named 2DArrayOperations with the following static
methods:
getTotal . This method should accept a
two-dimensional array as its argument and return the total of all
the values in the array. Write overloaded versions of this method
that work with int , double , and long arrays.
(A)
getAverage . This method should accept a
two-dimensional array as its argument and return the average of all
the values in the array. Write overloaded versions of...
You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must include all the following described methods. Each of these methods should be public and static.Write a method named getFirst, that takes an Array of int as an argument and returns the value of the first element of the array. NO array lists. Write a method named getLast, that takes an Array of int as an argument and returns the value of the last element...
IN C#.Develop a program that prints out the location of the largest value in a two-dimensional array. The largest values may appear more than once in the array, so you must only print out the first instance. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints...
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...
SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location of the first largest value in a two-dimensional array. The largest values may appear more than once in the array. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints out...
Write a Java class named Employee to meet the
requirements described in the UML Class Diagram below:
Note: Code added in the toString cell are not usually included
in a regular UML class diagram. This was added so you can
understand what I expect from you.
If your code compiles cleanly, is defined correctly and
functions exactly as required, the expected output of your program
will solve the following problem:
“An IT company with four departments and a staff strength...