Java Programming Assignment
Write a class named 2DArrayOperations with the following static methods:
Demonstrate the class in a complete program with test data stored in two-dimensional arrays of various data types. (G)
SAMPLE RUN & SCREENSHOT PROVIDED
![int[][] iarray- 2, 1, 9}, 1 7, 3, 4 ); double [] [] darray- 98.7, 89.2, 55.1 ), 1 77.6, 99.9, 62.2 ; long[] [] larray- t 100,](http://img.homeworklib.com/questions/c2116e20-d585-11ea-b726-9d16feb13f9b.png?x-oss-process=image/resize,w_560)

SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
/*package whatever //do not write package name here */
import java.io.*;
class TwoDArrayOperations
{
public static int getTotal(int[][] arr)
{
int sum=0;
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[i].length;j++)
{
sum+=arr[i][j];
}
}
return sum;
}
public static long getTotal(long[][] arr)
{
long sum=0;
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[i].length;j++)
{
sum+=arr[i][j];
}
}
return sum;
}
public static double getTotal(double[][] arr)
{
double sum=0;
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[i].length;j++)
{
sum+=arr[i][j];
}
}
return sum;
}
public static double getAverage(int[][] arr)
{
double count=0;
for(int i=0;i<arr.length;i++)
{
count+=arr[i].length;
}
return getTotal(arr)/count;
}
public static double getAverage(double[][] arr)
{
double count=0;
for(int i=0;i<arr.length;i++)
{
count+=arr[i].length;
}
return getTotal(arr)/count;
}
public static double getAverage(long[][] arr)
{
double count=0;
for(int i=0;i<arr.length;i++)
{
count+=arr[i].length;
}
return getTotal(arr)/count;
}
public static int getRowTotal(int[][] arr,int row)
{
int sum=0;
for(int i=0;i<arr[row].length;i++)
{
sum+=arr[row][i];
}
return sum;
}
public static long getRowTotal(long[][] arr,int row)
{
long sum=0;
for(int i=0;i<arr[row].length;i++)
{
sum+=arr[row][i];
}
return sum;
}
public static double getRowTotal(double[][] arr,int row)
{
double sum=0;
for(int i=0;i<arr[row].length;i++)
{
sum+=arr[row][i];
}
return sum;
}
public static double getHighestInRow(double[][] arr,int row)
{
double highest=0;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]>highest)
highest=arr[row][i];
}
return highest;
}
public static long getHighestInRow(long[][] arr,int row)
{
long highest=0;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]>highest)
highest=arr[row][i];
}
return highest;
}
public static int getHighestInRow(int[][] arr,int row)
{
int highest=0;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]>highest)
highest=arr[row][i];
}
return highest;
}
public static double getLowestInRow(double[][] arr,int row)
{
double lowest=99999;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]<lowest)
lowest=arr[row][i];
}
return lowest;
}
public static long getLowestInRow(long[][] arr,int row)
{
long lowest=99999;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]<lowest)
lowest=arr[row][i];
}
return lowest;
}
public static int getLowestInRow(int[][] arr,int row)
{
int lowest=99999;
for(int i=0;i<arr[row].length;i++)
{
if(arr[row][i]<lowest)
lowest=arr[row][i];
}
return lowest;
}
public static long getColumnTotal(long[][] arr,int column)
{
long sum=0;
for(int i=0;i<arr.length;i++)
{
sum+=arr[i][column];
}
return sum;
}
public static double getColumnTotal(double[][] arr,int
column)
{
double sum=0;
for(int i=0;i<arr.length;i++)
{
sum+=arr[i][column];
}
return sum;
}
public static int getColumnTotal(int[][] arr,int column)
{
int sum=0;
for(int i=0;i<arr.length;i++)
{
sum+=arr[i][column];
}
return sum;
}
public static void main (String[] args)
{
int[][] iarray={ {2,1,9},{7,3,4} };
double[][] darray={ {98.7,89.2,55.1}, {77.6,99.9,62.2}
};
long[][] larray={ {100,500,200},{300,400,900} };
TwoDArrayOperations op=new
TwoDArrayOperations();
/************************************ INT
**********/
System.out.println("Processing the int array.");
System.out.println("Total:
"+TwoDArrayOperations.getTotal(iarray));
System.out.println("Average:
"+TwoDArrayOperations.getAverage(iarray));
System.out.println("Total of Row 0:
"+TwoDArrayOperations.getRowTotal(iarray,0));
System.out.println("Total of Row 1:
"+TwoDArrayOperations.getRowTotal(iarray,1));
System.out.println("Total of Column 0:
"+TwoDArrayOperations.getColumnTotal(iarray,0));
System.out.println("Total of Column 2:
"+TwoDArrayOperations.getColumnTotal(iarray,2));
System.out.println("Highest in Row 0:
"+TwoDArrayOperations.getHighestInRow(iarray,0));
System.out.println("Highest in Row 1:
"+TwoDArrayOperations.getHighestInRow(iarray,1));
System.out.println("Lowest of Row 0:
"+TwoDArrayOperations.getLowestInRow(iarray,0));
System.out.println("Lowest of Row 1:
"+TwoDArrayOperations.getLowestInRow(iarray,1));
/************************************ DOUBLE
**********/
System.out.println("\nProcessing the Double
array.");
System.out.println("Total:
"+TwoDArrayOperations.getTotal(darray));
System.out.println("Average:
"+TwoDArrayOperations.getAverage(darray));
System.out.println("Total of Row 0:
"+TwoDArrayOperations.getRowTotal(darray,0));
System.out.println("Total of Row 1:
"+TwoDArrayOperations.getRowTotal(darray,1));
System.out.println("Total of Column 0:
"+TwoDArrayOperations.getColumnTotal(darray,0));
System.out.println("Total of Column 2:
"+TwoDArrayOperations.getColumnTotal(darray,2));
System.out.println("Highest in Row 0:
"+TwoDArrayOperations.getHighestInRow(darray,0));
System.out.println("Highest in Row 1:
"+TwoDArrayOperations.getHighestInRow(darray,1));
System.out.println("Lowest of Row 0:
"+TwoDArrayOperations.getLowestInRow(darray,0));
System.out.println("Lowest of Row 1:
"+TwoDArrayOperations.getLowestInRow(darray,1));
/*********************************** LONG ***************/
System.out.println("\nProcessing the Long array.");
System.out.println("Total:
"+TwoDArrayOperations.getTotal(larray));
System.out.println("Average:
"+TwoDArrayOperations.getAverage(larray));
System.out.println("Total of Row 0:
"+TwoDArrayOperations.getRowTotal(larray,0));
System.out.println("Total of Row 1:
"+TwoDArrayOperations.getRowTotal(larray,1));
System.out.println("Total of Column 0:
"+TwoDArrayOperations.getColumnTotal(larray,0));
System.out.println("Total of Column 2:
"+TwoDArrayOperations.getColumnTotal(larray,2));
System.out.println("Highest in Row 0:
"+TwoDArrayOperations.getHighestInRow(larray,0));
System.out.println("Highest in Row 1:
"+TwoDArrayOperations.getHighestInRow(larray,1));
System.out.println("Lowest of Row 0:
"+TwoDArrayOperations.getLowestInRow(larray,0));
System.out.println("Lowest of Row 1:
"+TwoDArrayOperations.getLowestInRow(larray,1));
}
}
========================================================
OUTPUT:
Processing the int array.
Total: 26
Average: 4.333333333333333
Total of Row 0: 12
Total of Row 1: 14
Total of Column 0: 9
Total of Column 2: 13
Highest in Row 0: 9
Highest in Row 1: 7
Lowest of Row 0: 1
Lowest of Row 1: 3
Processing the Double array.
Total: 482.7
Average: 80.45
Total of Row 0: 243.0
Total of Row 1: 239.7
Total of Column 0: 176.3
Total of Column 2: 117.30000000000001
Highest in Row 0: 98.7
Highest in Row 1: 99.9
Lowest of Row 0: 55.1
Lowest of Row 1: 62.2
Processing the Long array.
Total: 2400
Average: 400.0
Total of Row 0: 800
Total of Row 1: 1600
Total of Column 0: 400
Total of Column 2: 1100
Highest in Row 0: 500
Highest in Row 1: 900
Lowest of Row 0: 100
Lowest of Row 1: 300
=============================================================
SCREENSHOTS:


![68 69 7e 71 72 73 74- 75 76 public static int getRowTotal(int[[] arr,int row) int sum-0; for(int i-e;icarr[row].length;i+) su](http://img.homeworklib.com/questions/0ba40d00-d586-11ea-b7ed-3790b1459c7d.png?x-oss-process=image/resize,w_560)


![164 165 166 167- 168 169 170 public static long getColumnTotal(long[1I] arr,int column) long sum-e; for(int i-0;iarr.length;i](http://img.homeworklib.com/questions/0cddb9a0-d586-11ea-8f7e-635d9ff7e509.png?x-oss-process=image/resize,w_560)
![197 198 public static void main (Stringl] args) int[][] İarray={ {2,1,9),(7,3,4} }; double[)[] darray-198.7,89.2,55.1, 77.6,9](http://img.homeworklib.com/questions/0d447370-d586-11ea-a962-f7b968359101.png?x-oss-process=image/resize,w_560)

===========================================================
If there are any doubts, comment down here. We are right here to help you. Happy Learning..!!
===========================================================
Java Programming Assignment Write a class named 2DArrayOperations with the following static methods: getTotal . This...
Java Programming (use jGrasp if not thats fine) Write a Two classes one class that creates a two-dimensional 2 rows by 3 columns double array. This class will have a separate method for the user to populate the array with data values. The other class that has the following methods: getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array. getAverage. This method should accept a two-dimensional array...
This is java, please follow my request and use netbeans.
Thank you.
A3 15. 2D Array Operations Write a program that creates a two-dimensional array initialized with test data. Use any primitive data type that you wish. The program should have the following methods: • getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array. .getAverage. This method should accept a two-dimensional array as its argument and return...
Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...
Please solve only if you know how to do it. Write the code using
C++ (not Python or Java). Show and explain everything neatly.
COMMENTS (7.5% of programming assignment grade): Your program should have at least ten (10) different detailed comments explaining the different parts of your program. Each individual comment should be, at a minimum, a sentence explaining a particular part of your code. You should make each comment as detailed as necessary to fully explain your code. You...
Arrays In this homework, create two arrays – studentName and studentScore (String and Int types). Write a method (getData) that would ask user to enter a set of data – for example, five student names and corresponding scores. This program should also have the following methods: getSum. This method should accept a studentScore array as its argument and return the sum of the values in the array. getAverage. This method should accept a studentScore array as its argument...
JAVA HELP (ARRAYS)
Assignment Create a class named Module4 containing the following data members and methods (note that all data members and methods are for objects unless specified as being for the entire class) 1) Data members: none 2) Methods a. A method named displayContents that accepts an array of type int and prints their values to the b. A method named cemoveNegatives that accepts an array of type int, copies all its non-negative the new array should be the...
Java 1. Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. 2. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in...
In this homework, create two arrays – studentName and studentScore (String and Int types). Write a method (getData) that would ask user to enter a set of data – for example, five student names and corresponding scores. This program should also have the following methods: getSum. This method should accept a studentScore array as its argument and return the sum of the values in the array. getAverage. This method should accept a studentScore array as its argument and...
Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment...
Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...