Advertisement
Guest User

Untitled

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