Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package IntroToJava;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Target {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int target = Integer.parseInt(scanner.nextLine());
  9.         for (int num = 1; num < target && num <= 20; num++) {
  10.             if (target - num >= 1 && target - num <= 20)
  11.                 System.out.printf("%d + %d = %d\n", num, target - num, target);
  12.         }
  13.  
  14.         for (int num = 1; num <= 20 - target; num++) {
  15.             if (target + num >= 1 && target + num <= 20)
  16.                 System.out.printf("%d - %d = %d\n", num + target, num, target);
  17.         }
  18.  
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement