Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package IntroToJava;
- import java.util.Scanner;
- public class Target {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int target = Integer.parseInt(scanner.nextLine());
- for (int num = 1; num < target && num <= 20; num++) {
- if (target - num >= 1 && target - num <= 20)
- System.out.printf("%d + %d = %d\n", num, target - num, target);
- }
- for (int num = 1; num <= 20 - target; num++) {
- if (target + num >= 1 && target + num <= 20)
- System.out.printf("%d - %d = %d\n", num + target, num, target);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement