Question: Java language Question: Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample
Java language
Question:
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program:
Min miles: -10 Max miles: 40
Code:
import java.util.Scanner;
public class ArraysKeyValue { public static void main (String [] args) { final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i; int j; int maxMiles; // Assign with first element in milesTracker before loop int minMiles; // Assign with first element in milesTracker before loop
milesTracker[0][0] = -10; milesTracker[0][1] = 20; milesTracker[1][0] = 30; milesTracker[1][1] = 40; /* Your solution goes here */ System.out.println("Min miles: " + minMiles); System.out.println("Max miles: " + maxMiles); } }
Screenshot

CHALLENGE ACTIVITY 5.9.1: Find 2D array max and min. Find the maximum value and minimum value in miles Tracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given progranm Min miles: -10 Max miles: 40 (Notes) 1 import java.util.Scanner; 3 public class ArraysKeyValue 4 public static void main (String [] args)t 1 test passed final int NUM_ROWS2; final int NUM-COLS 2; int milesTracker new int NUM ROWS NUM COLS]; int i; All tests passed 10 int maxMiles; I/ Assign with first element in milesTracker before loop int minMiles; // Assign with first element in milesTracker before loop 12 13 14 15 16 17 18 milesTracker[0][0] --10; milesTracker[0]1]-20; milesTracker[1]00]-30; milesTracker[1]1]-40; Your solution goes here System.out.println("Min miles: "+ minMiles); System.out.println("Max miles: "maxMiles)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
