Advertisement
yanivtamari

29.05(4)

May 29th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner s = new Scanner(System.in);
  7.         int[] arr = new int[5];
  8.         System.out.printf("please enter %d numbers ", arr.length);
  9.         for (int i = 0; i < arr.length; i += 1)
  10.             arr[i] = s.nextInt();
  11.         System.out.println("The Answer is: ");
  12.         for (int i = 0; i < arr.length; i += 2) {
  13.             System.out.printf("%d ", (arr[i] + 1));
  14.         }
  15.  
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement