Advertisement
CR7CR7

MathMaxMin

Sep 12th, 2022
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package com.telerikacademy;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class MathMaxMin {
  6.     public static void main(String[] args) {
  7.         // Read three numbers from the console
  8.         Scanner scanner = new Scanner(System.in);
  9.         int a = scanner.nextInt();
  10.         int b = scanner.nextInt();
  11.         int c = scanner.nextInt();
  12.  
  13.         // Find the biggest of them
  14.         int greatest = Math.max(a, Math.max(b, c));
  15.  
  16.         // Find the smallest of them
  17.         int smallest = Math.min(a, Math.min(b, c));
  18.  
  19.         // Print the sum of the biggest and the smallest
  20.         System.out.println(greatest + smallest);
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement