Advertisement
iskren_penev

HitTheTarget

Mar 18th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package softuni.homework.problem9;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HitTheTarget {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.         int target = input.nextInt();
  9.         for (int i = 1; i <= 20 ; i++) {
  10.             for (int j = 1; j <= 20 ; j++) {
  11.                 if ( i + j == target){
  12.                     System.out.printf("%d + %d = %d\r\n", i, j, target);
  13.                 }
  14.                 if (i - j == target) {
  15.                     System.out.printf("%d - %d = %d\r\n", i, j, target);
  16.                 }
  17.             }
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement