Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Sandbox {
- public static void main(String args[]) {
- try {
- Scanner sc = new Scanner(System.in);
- /*
- Random rnd = new Random();
- int a = rnd.nextInt(2001) - 1000;
- int b = rnd.nextInt(2001) - 1000;
- int c = rnd.nextInt(2001) - 1000;
- System.out.println(a);
- System.out.println(b);
- System.out.println(c);
- */
- int [] numbers = { 0, 0, 0, 0 };
- System.out.print("Enter four numbers: ");
- numbers[0] = sc.nextInt();
- numbers[1] = sc.nextInt();
- numbers[2] = sc.nextInt();
- numbers[3] = sc.nextInt();
- int max = Math.max(Math.max(numbers[0], numbers[1]), Math.max(numbers[2], numbers[3]));
- System.out.format("You have entered: %d %d %d %d\n",
- numbers[0], numbers[1], numbers[2], numbers[3]
- );
- System.out.println("Maximum is " + max);
- sc.close();
- } catch(Exception e){
- System.out.println("Unexpected error, sorry!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement