The program should display the maximum of the N entered numbers.
it says ...be sure that the program works correctly for large negative numbers such as -2000000000
package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
//reads a number n from the console
int n = Integer.parseInt(buffer.readLine());
//only do something if n > 0
if (n >0)
{
//read n numbers from the console, set the first number to maximum
int maximum = Integer.parseInt(buffer.readLine());
do {
int readNum = Integer.parseInt(buffer.readLine());
if (readNum >= maximum)
maximum=readNum;
n = n-1;
} while (n > 1);
System.out.println(maximum);
}
}
}