JAVA
Write a program that repeatedly reads in integers until a negative integer is read. The program also keeps track of the largest integer that has been read so far and outputs the largest integer at the end.

Ex: If the input is:
2 77 17 4 -1

the output is:
77
Assume a user will enter at least one non-negative integer.

Respuesta :

The program is an illustration of loops

What are loops?

Loops are program statements that are used to execute repeated statements

The java program

The program, written in Java where comments are used to explain each line is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int num;

//Get input from the user

 num = input.nextInt();

//Initialize the largest to the first input

 int maxn = num;

//This loop is repeated until a negative input is recorded

 while (num >=0){

//If the current input is greater than the previous largest

     if (num>maxn){

//Set largest to the current input

         maxn = num;      }

//Get another input from the user

     num = input.nextInt();

 }

//Print the largest

 System.out.print("Largest: "+maxn);

}

}

Read more about loops at:

https://brainly.com/question/14284157