Advertisement
CoineTre

JF-ExcMethods01.SmallestNumber

Feb 5th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Exc1SmallestNumber {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int a = Integer.parseInt(scanner.nextLine());
  8.         int b = Integer.parseInt(scanner.nextLine());
  9.         int c = Integer.parseInt(scanner.nextLine());
  10.         System.out.println(getSmallestNumber(a,b,c));
  11.  
  12.     }
  13.  
  14.     private static int getSmallestNumber(int a, int b, int c) {
  15.         return getSmallestNumber(getSmallestNumber(a,b),c);
  16.     }
  17.  
  18.     private static int getSmallestNumber(int a, int b) {
  19.         if (a<b){
  20.             return a;
  21.         }
  22.         return b;
  23.     }
  24.  
  25.  
  26. }
  27. //Write a method to print the smallest of three integer numbers. Use appropriate name for the method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement