veronikaaa86

07. Min Number

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