Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

1. Does the survey prompt discussions with your direct reports?

Answered: 1 week ago

Question

1. Explain why evaluation is important.

Answered: 1 week ago