# Hi, I am programming in java. The instructions require:Create a new project and call it Project8.Create a dual array 10x10 and initialize it with random numbers, range 0 to 100.Example: int[][] ary = new int;Create a method that finds the largest number in the array.Create a method that calculates the sum of a single row. Make the method flexible such that it can calculate the sum of any specified row.Display the sum of each row. The code must be well structured, use method where possible.  Please include detailed information and steps to how to solve this. Thank you! This is what I have thus far://Brianna Fisher COMP 1000import java.util.Random;import java.util.Arrays;public class Project8{static int ary; public static void main(String[] args){int[][] ary = new int;Random rnd = new Random (-1);for(int row = 0; row < 10; row++) {for(int col = 0; col < 10; col++) {ary[row][col] = rnd.nextInt(100);}}for(int row = 0; row < 10; row++)for(int col = 0; row <10; col++){System.out.println(Arrays.toString(ary[row]));}

Question
21 views

Hi, I am programming in java. The instructions require:

Create a new project and call it Project8.

Create a dual array 10x10 and initialize it with random numbers, range 0 to 100.

Example: int[][] ary = new int;

Create a method that finds the largest number in the array.

Create a method that calculates the sum of a single row. Make the method flexible such that it can calculate the sum of any specified row.

Display the sum of each row.

The code must be well structured, use method where possible.

Please include detailed information and steps to how to solve this. Thank you!

This is what I have thus far:

//Brianna Fisher COMP 1000
import java.util.Random;
import java.util.Arrays;

public class Project8
{

static int ary;

public static void main(String[] args)
{

int[][] ary = new int;
Random rnd = new Random (-1);

for(int row = 0; row < 10; row++)
{
for(int col = 0; col < 10; col++)
{
ary[row][col] = rnd.nextInt(100);
}
}

for(int row = 0; row < 10; row++)
for(int col = 0; row <10; col++)
{
System.out.println(Arrays.toString(ary[row]));

}

check_circle

Step 1

Program algorithm-

START

Step1: Import the essential java packages.

Step2: Define the class Project8

Step3: Define the main method.

Step4: Prompt the user to enter the row number to display the sum of specific row.

Step5: Declare all the variables and their datatypes accordingly.

Step6: Define a 2-D array as int datatype.

Step7: Use for loop to iterate over rows and columns

Step8: Define a non-static method to calculate the sum of each row individually.

Step9: Display the highest number in the array.

Step10: Call the non-static method from static method to display all the rows on the console.

END

Step 2

Code (in java)-

import java.util.Scanner;

public class Project8

{

//Declare and initialize the static variable

public static final int n = 11,m=11;

//Create Scanner object

Scanner in=new Scanner(System.in);

//Define the function to find the largest in an array

void highest(int[][] ary)

{

//Set first array value as maximum

int maxm=ary;

//Create "for" loop to iterate over row

for(int row=1;row<=10;row++)

{

//Create "for" loop to iterate over column

for (int col=1;col<=10;col++)

{

//Check whether the array element is greater than maximum

if(ary[row][col]>maxm)

//Assign the maximum value

maxm=ary[row][col];

}

}

//Print the largest value in an array

System.out.println("The highest element in the array is  "+maxm);

}

//Define the method to display the sum of specified row

public void sumsinglerow(int[][] ary)

{

//Declare and initialize necessary variables

int c=0;

int sum=0;

int sumOfrow= 0;

//Prompt the user to enter the row

System.out.print("Enter the row number to display the sum: ");

//Get the row from the user

int sp=in.nextInt();

//Create "for" loop to iterate over row

for(int row=1;row<=10;row++)

{

//Create for loop to iterate over column

for(int col=1;col<=10;col++)

{

//Calculate sum of the row elements

sumOfrow+=ary[row][col];

//Increase the counter variable

c++;

//Check whether the count is "10"

if(c==10)

{

//Calculate the total sum value

sum+=sumOfrow;

//Check whether the current row is equal to the specified row

if(row==sp)

//Print the sum of specified row

System.out.println("The sum of specified row "+sp+" is :"+sumOfrow);

//Set count to "0"

c=0;

//Set the value to "0"

sumOfrow=0;

}

}

}

}

//Defining the main method

public static void main(String[] args)

{

//Declare and initialize all the necessary variables

int c=0;

int sum=0;

//Defining array

int[][] ary = new int[n][m];

int sumOfrow= 0;

//Create object

Project8 r=new Project8();

//Creating for loop to iterate over each row

for(...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Programing Language 