Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Rewrite the MinMax class shown down below so that it uses a for-each style for loop. (MUST USE JAVA - SIMPLE JAVA) class MinMax {
Rewrite the MinMax class shown down below so that it uses a for-each style for loop. (MUST USE JAVA - SIMPLE JAVA)
class MinMax { }
public static void main(String[] args) {
int[] nums = new int[10]; int min, max; }
nums[0] = 99;
nums[1] = -10;
nums[2] = 100123;
nums[3] = 18;
nums[4] = -978;
nums[5] = 5623;
nums[6] = 463;
nums[7] = -9;
nums[8] = 287;
nums[9] = 49;
min = max = nums[0];
for(int i=1; i < 10; i++) {
if(nums[i] < min) min = nums[i];
if(nums[i] > max)
max = nums[i]; }
System.out.println("min and max: " + min + " " + max);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started