Advertisement
veronikaaa86

06. Max Number

Jun 4th, 2022
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package whileLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06MaxNumber {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int maxNum = Integer.MIN_VALUE;
  10. String input = scanner.nextLine();
  11. while (!input.equals("Stop")) {
  12. int currentNum = Integer.parseInt(input);
  13.  
  14. if (currentNum > maxNum) {
  15. maxNum = currentNum;
  16. }
  17.  
  18. input = scanner.nextLine();
  19. }
  20.  
  21. System.out.println(maxNum);
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement