Advertisement
bogolyubskiyalexey

Calc numbers. Example with array

Sep 7th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.IOException;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) throws Exception {
  6.         Scanner scan = new Scanner(System.in);
  7.         final int N = 3;
  8.         int[] array = new int[N];
  9.         int a=0, b=0;
  10.         for (int i=0; i < array.length; i++)
  11.         {
  12.             array[i] = scan.nextInt();
  13.             if (array[i] > 0)
  14.                 a++;
  15.             if (array[i] < 0)
  16.                 b++;
  17.         }
  18.         System.out.println("количество отрицательных чисел: "+b);
  19.         System.out.println("количество положительных чисел: "+a);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement