Write a function named findmax()that finds and displays the maximum values in a two dimensional array of integers. The array should be declared as a 10 row by 15 column array of integers in main()and populated with random numbers between 0 and 100.

Answers

Answer 1

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

    Random r = new Random();

    int[][] numbers = new int[10][15];

   

    for (int i=0; i<10; i++){

        for (int j=0; j<15; j++){

            numbers[i][j] = new Random().nextInt(101);

        }

    }

   

    for (int i=0; i<10; i++){

        for (int j=0; j<15; j++){

            System.out.print(numbers[i][j] + " ");

        }

        System.out.println();

    }

   

    findmax(numbers);

}

public static void findmax(int[][] numbers){

    int max = numbers[0][0];

   

    for (int i=0; i<10; i++){

        for (int j=0; j<15; j++){

            if(numbers[i][j] > max)

                max = numbers[i][j];

        }

    }

    System.out.println("The max is " + max);

}

}

Explanation:

*The code is in Java.

Create a function called findmax() that takes one parameter, numbers array

Inside the function:

Initialize the max as first number in the array

Create a nested for loop that iterates through the array. Inside the second for loop, check if a number is greater than the max. If it is set it as the new max

When the loop is done, print the max

Inside the main:

Initialize a 2D array called numbers

Create a nested for loop that sets the random numbers to the numbers array. Note that to generate random integers, nextInt() function in the Random class is used

Create another nested for loop that displays the content of the numbers array

Call the findmax() function passing the numbers array as a parameter


Related Questions

Are Dogs are better than video games?

Answers

sometimes bc dogs are very lovey but video games also have there moments

Answer:

In some cases yes.

Explanation:

Some days I really enjoy my video games and other days I enjoy being with my dog but sometimes they are annoying especially if they have way more energy than you

Other Questions
Suppose US$1 = 0.7809 in New York and US$1 = 0.7793 in Paris. How can foreign exchange traders profit from these exchange rates? What actions can they take that may result in the same dollar/euro exchange rate in both New York and Paris? Please limit your response to one or two reasonably-sized paragraphs. Reorder the following sentences in the correct order.1- It is mainly formal, impersonal and objective .2- In most of these the writer is expected to include references to other writing or research.3- Academic writing is a particular kind of writing, that can be recognised by its style .4- These includes essays, reseach reports and articles , case studies , surveys, dissertations , thesis , and examination papers .5- Other distinctive features will depend upon the specific types of academic writing . The author uses flashback in this story to show A. the misunderstanding between Rob and Adrian. B. the deteriorating health condition of Piyush. C. the history of Rob and Piyush's friendship. D. the relationship of Adrian and Rob's family. "She finished the sprint with the speed of a cheetah." This statement represents which of thefollowing functions of language? (2 points)correct answer is poetic. Help ASAP ASAP number 6 Based on historical data, your manager believes that 30% of the company's orders come from first-time customers. A random sample of 64 orders will be used to estimate the proportion of first-time-customers. What is the probability that the sample proportion is greater than than 0.2? Once a player catches the Frisbee they are only allowed to pivot like inbasketball. TrueFalse What decimal is equivalent to 21% ?HELP ASAP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Using the divisibility rules, explain why 678 is divisible by 2, 3, and 6. Please Help. I'll give brainliest. DONT ANSWER IF YOU DONT KNOW I WILL REPORT AND YOU WONT EARN ANY POINTS. everyone,you are AMAZINGyou are BEAUTIFULyou are SMARTyou are KINDyou are NOT going to give up on your FIGHTand you better stay ALIVE (03.07 MC)A 660 kg car is travelling around a circular track of radius 55.0 m at 11.5 m/s.Calculate the force and its direction that provides the centripetal force acting on the car to keep itin the circular path. (3 points)a) 24 N toward the center of the circleb) 24 N along the line tangent to the circlec) 1.587 E3 N along the line tangent to the circled) 1.587 E3 N toward the center of the circle bruh ur no help its not even a answer dumbo Translate: I love you a lot.Te amo muchamente.Te amo poco.Te amo muyTe amo mucho. How many 1000-Watt lights can be plugged into a standard 120-Volt, 15-Amp outlet? (Hint: W/V=A) * Giving brainiest explain answer Which sets of values belongs to the domain and range of a relation LOOKING BACKChildren, I have here different school scenarios. Supposed to be that youare going to role play the characters with your classmates in the picture. Thinkof questions to ask to initiate conversation with your peers.What are some questions that you could ask to yourclassmate to start conversationQUESTIONSWhoWhatWhereWhenWhyHowDoDidCanisAreHave A skier rides horizontally off of a 200 meter high cliff. If he lands 25 meters away fromthe base of the cliff, how fast was he skiing as he went off the edge? President Theodore Roosewer's foreign policy served to increase US involvement in -China's Boxer RebellionHawai's pineapple industrylatin american affairs European alliance systems