Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Collection
- {
- private static Scanner scanner = new Scanner(System.in);
- public static void main(String[] args)
- {
- int dimension = dimensionCounter(scanner);
- collectionFiller(scanner, dimension);
- scanner.close();
- }
- public static int dimensionCounter(Scanner scanner)
- {
- //Введение размерности массива чисел
- System.out.print("Dimension: ");
- int dimension = Integer.parseInt(scanner.nextLine());
- System.out.printf("Enter dimension: %d \n", dimension);
- return dimension;
- }
- public static void collectionFiller(Scanner scanner, int dimension)
- {
- int[] collection;
- collection = new int[dimension];
- //Цикл ввода элементов массива
- int i = 0;
- while (i < dimension)
- {
- System.out.print("Enter char "+ (i+1) +":");
- collection[i] = scanner.nextInt();
- System.out.printf("Char entered: %d \n", collection[i]);
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement