Ask Question
7 December, 10:31

Write a program with loop that lets the use enter a series of integers. The user should enter - 1 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.

+2
Answers (1)
  1. 7 December, 10:46
    0
    import java. util. ArrayList;

    import java. util. Scanner;

    import java. util. Collections;

    public class num6 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    int num;

    ArrayList al=new ArrayList ();

    do{

    System. out. println ("Enter a series of integers. To quit enter - 1");

    num = in. nextInt ();

    al. add (num);

    }while (num>=0);

    System. out. println ("The minimum Value: " + Collections. min (al));

    System. out. println ("The Maximum Value: " + Collections. max (al));

    }

    }

    Explanation:

    Create an ArrayList Object Prompt user to continually enter integer values (while numbers is >=0) Store the values in the ArrayList Use the Collections. min Method to print the smallest value Use Collections. max Method to print the largest value
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program with loop that lets the use enter a series of integers. The user should enter - 1 to signal the end of the series. After ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers