Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.ArrayList; import java.util.Scanner; /* * This program finds the largest and smallest numbers in an array list of integers */ public class FindMinAndMax {

import java.util.ArrayList;
import java.util.Scanner;
/*
* This program finds the largest and smallest numbers in an array list of integers
*/
public class FindMinAndMax
{
   public static void main(String[] args)
   {
      String data = "45 72 35 90 12 3 204 317 684 23 44";
      ArrayList values = new ArrayList();
     
      Scanner in = new Scanner(data);
      while (in.hasNextInt())
      {
         values.add(in.nextInt());
      }

      // Find the largest and smallest value in array list values
int largest  = values.get(0);
      int smallest = values.get(0);
      //-----------Start below here. To do: approximate lines of code = 5
      // Loop through the remaining integer elements in values and update largest and smallest
     
     
     
     
     
     
     
     
     
     
     
      //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
      System.out.println("Largest = " + largest + " Smallest = " + smallest);
      System.out.println("Expected:Largest = 684 Smallest = 3");
   }
}


P.S: Please write the code as well as include screenshots for reference along with output

Step by Step Solution

3.40 Rating (147 Votes )

There are 3 Steps involved in it

Step: 1

import javautilArrayList import javautilScanner This program finds the largest and smalles... 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_2

Step: 3

blur-text-image_3

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

Physics Principles with Applications

Authors: Douglas C. Giancoli

7th edition

978-0321869111, 321625927, 9780321733627, 321869117, 9780321625922, 321733622, 978-0321762429

More Books

Students also viewed these Programming questions

Question

What are the purposes of promotion ?

Answered: 1 week ago

Question

Define promotion.

Answered: 1 week ago