Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, jabezslade22
What is the first view you place in your drawing?
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, alannaamarriee
Jace needs to answer a question on square roots to win a quiz. how can he use a spreadsheet to find the square root of 786? a. use the functions round and count b. create a table and chart c. use the function sqrt d. use the function now
Answers: 3
image
Computers and Technology, 23.06.2019 21:40, minnie7760
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
image
Computers and Technology, 24.06.2019 08:00, qveenvslayin
How can smart devices benefit businesses, organizations, and social communities in the global marketplace?
Answers: 1
Do you know the correct answer?
1. Complete the following program so that it computes the maximum and minimum of the elements in the...

Questions in other subjects:

Konu
Mathematics, 02.06.2021 01:50
Konu
English, 02.06.2021 01:50