Advertisement
veronikaaa86

07. Min Number

Apr 1st, 2023
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 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.         int minNum = Integer.MAX_VALUE;
  10.         String input = scanner.nextLine();
  11.         while (!input.equals("Stop")) {
  12.             int currentNum = Integer.parseInt(input);
  13.  
  14.             if (currentNum < minNum) {
  15.                 minNum = currentNum;
  16.             }
  17.  
  18.             input = scanner.nextLine();
  19.         }
  20.  
  21.         System.out.println(minNum);
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement