wadkat

java find largest number

Nov 2nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. package javalesson6;
  3. import java.util.Scanner;
  4.  
  5. public class Javalesson6 {
  6.  
  7.  
  8. public static void main(String[] args)
  9. {
  10. {
  11. int x, y, z;
  12. System.out.println("Enter three integers");
  13. Scanner in = new Scanner(System.in);
  14.  
  15. x = in.nextInt();
  16. y = in.nextInt();
  17. z = in.nextInt();
  18.  
  19. if (x > y && x > z)
  20. System.out.println(x+" is largest.");
  21. else if (y > x && y > z)
  22. System.out.println(y+" is largest.");
  23. else if (z > x && z > y)
  24. System.out.println(z+" is largest.");
  25. else
  26. System.out.println("The numbers are not distinct.");
  27. }
  28.  
  29.  
  30. }}
Add Comment
Please, Sign In to add comment