Advertisement
veronikaaa86

06. Max Number

Jul 30th, 2022
404
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.  
  11. String inputLine = scanner.nextLine();
  12. while (!inputLine.equals("Stop")) {
  13. int currentNum = Integer.parseInt(inputLine);
  14.  
  15. if (currentNum > maxNum) {
  16. maxNum = currentNum;
  17. }
  18.  
  19. inputLine = scanner.nextLine();
  20. }
  21. System.out.println(maxNum);
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement