Advertisement
SUni2020

Sums3Numbers

Mar 28th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Sums3Numbers {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int a = Integer.parseInt(scanner.nextLine());
  7. int b = Integer.parseInt(scanner.nextLine());
  8. int c = Integer.parseInt(scanner.nextLine());
  9. if (a + b ==c) {
  10. if ( a > b ) {
  11. System.out.printf("%d + %d = %d", b, a, c);
  12. } else {
  13. System.out.printf("%d+ %d= %d", a, b,c);
  14. }
  15.  
  16.  
  17. } else if ( a + c == b) {
  18. if (a < c) {
  19. System.out.printf("%d + %d = %d", a, c, b);
  20. } else {
  21. System.out.printf("%d + %d = %d", c, a, b);
  22. }
  23. } else if (b+c == a) {
  24. if (b<c) {
  25. System.out.printf("%d + %d = %d",b,c,a);
  26. } else {
  27. System.out.printf("%d + %d = %d", c,b,a);
  28. }
  29.  
  30. } else
  31. System.out.println("No");
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement