Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Collection
  4. {
  5.         public static void main(String[] args)
  6.         {
  7.             try (Scanner scanner = new Scanner(System.in)) { collectionFiller(scanner, dimensionCounter(scanner)); }
  8.         }
  9.        
  10.         public static int dimensionCounter(Scanner scanner)
  11.         {
  12.             //Введение размерности массива чисел
  13.             System.out.print("Dimension: ");
  14.             int dimension = scanner.nextInt();
  15.             System.out.printf("Enter dimension: %d \n", dimension);
  16.             return dimension;
  17.         }
  18.  
  19.         public static void collectionFiller(Scanner scanner, int dimension)
  20.         {
  21.             int[] collection = new int[dimension];
  22.            
  23.             //Цикл ввода элементов массива
  24.             for (int i = 0; i < dimension; i++)
  25.             {
  26.                 System.out.print("Enter int "+ (i+1) +":");
  27.                 collection[i] = scanner.nextInt();
  28.                 System.out.printf("Char entered: %d \n",  collection[i]);
  29.             }
  30.         }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement