Challenge: Array of Integers
Explore how to create an array of integers in Scala, multiply each element by three, and filter the results to include only even numbers. This lesson helps you apply Scala array manipulation, understand range-based inputs, and improve your practical programming skills through a coding challenge.
We'll cover the following...
Problem Statement
You have to create and populate an array of integers within a given range. Multiply each element in the range with 3. The elements of the final array should only contain even numbers.
Input
The input is the lower bound minRange and upper bound maxRange of the range which you will use to populate the array.
minRangeandmaxRangehave already been declared for you.
Output
The output will be the populated finalArray.
Sample Input
(1, 5)
Sample Output
Array(6, 12)
Test Yourself
Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!
Let’s go over the solution review in the next lesson.