Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package whileLoop;
- import java.util.Scanner;
- public class P06MaxNumber {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine(); // 100 Stop
- int maxNum = Integer.MIN_VALUE; // -100 -20 -50 -250 -2147000000
- while (!input.equals("Stop")) {
- int currentNum = Integer.parseInt(input);
- if (currentNum > maxNum) {
- maxNum = currentNum;
- }
- input = scanner.nextLine();
- }
- System.out.println(maxNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement