subject

1. Complete the following program so that it computes the maximum and minimum of the elements in the array. Write the program so that it works even if the dimensions of the rows and columns are changed. (Use length rather than hard-coded numbers.) Think carefully about how max and min should be initialized. Debug your program by editing the array. Change it in unexpected ways, such as all negative values, or the largest element as the last, or first, or all elements the same.
import java. io.* ;
class ArrayMaxMin
{
public static void main ( String[] args )
{
int[][] data = { {3, 2, 5},
{1, 4, 4, 8, 13},
{9, 1, 0, 2},
{0, 2, 6, 3, -1, -8} };
// declare and initialize the max and the min
???
//
for ( int row=0; row < data. length; row++)
{
for ( int col=0; col < ???; col++)
{
???
}
}
// write out the results
System. out. println( "max = " + max + "; min = " + min );
}
}
2. Modify the program so that it computes and prints the largest element in each row.
Requirements: Looping, bounds checking, initializer lists.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:50
Python write an expression that executes the loop body as long as the user enters a non-negative number. note: if the submitted code has an infinite loop, the system will stop running the code after a few seconds and report "program end never reached." the system doesn't print the test case that caused the reported message. sample outputs with inputs: 9 5 2 -1
Answers: 3
question
Computers and Technology, 24.06.2019 04:30
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe and
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
question
Computers and Technology, 24.06.2019 21:40
Clunker motors inc. is recalling all vehicles in its extravagant line from model years 1999—2002 as well as all vehicles in its guzzler line from model years 2004—2007. a boolean variable named recalled has been declared. given a variable modelyear and a string modelname, write a statement that assigns true to recalled if the values of modelyear and modelname match the recall details and assigns false otherwise.
Answers: 2
You know the right answer?
1. Complete the following program so that it computes the maximum and minimum of the elements in the...
Questions
question
Chemistry, 11.01.2021 09:50
question
Advanced Placement (AP), 11.01.2021 09:50
question
Chemistry, 11.01.2021 09:50
question
Social Studies, 11.01.2021 09:50
question
Social Studies, 11.01.2021 09:50
question
Mathematics, 11.01.2021 09:50
Questions on the website: 13722361