004-002-014

Array Creation: Multiple Arrays

Medium

Problem Description

Array Creation: Multiple Arrays

In this problem, you will create a program that reads two integers from standard input (the sizes of scores and grades arrays), creates arrays of those sizes, uses the .length property to retrieve each array's size, and displays both individual lengths and their total element count to standard output.

Learning Objective: Understand how to create multiple arrays using Scanner-provided sizes and get their lengths

Overview

Create a program that reads each array's size from standard input, creates two arrays of different sizes, and outputs their lengths and total element count.

Input Format

size of scores array
size of grades array

Specifications

  • Read two integers from standard input (line 1: size of scores, line 2: size of grades)
  • Create an integer array named scores with the given size
  • Create a char array named grades with the given size
  • Output the length of each array
  • Calculate and output the total number of elements

Input/Output Example

Input:

4
6

Output:

Scores length: 4
Grades length: 6
Total elements: 10

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up