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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:10, o10922025
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, briannaleiigh
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
image
Computers and Technology, 23.06.2019 17:30, kenyasutton10
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, kayranicole1
What shows the web address of the page that is currently displayed in the workspace? status window toolbar location bar internet box
Answers: 1
You know the right answer?
1. Complete the following program so that it computes the maximum and minimum of the elements in the...

Questions in other subjects: