Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Two-Dimensional Array Instruction: Create a java program that generates elements (randomly from 10-50) of a 2-dimensional array (5x5) using the Random Class then perform the

Two-Dimensional Array

Instruction: Create a java program that generates elements (randomly from 10-50) of a 2-dimensional array (5x5) using the Random Class then perform the following:

1. Output the array elements. 2. Output the sum of prime numbers in the array. 3. Output the elements in the main diagonal. 4. Output the sum of the elements below the diagonal. 5. Output the sum of the elements above the diagonal. 6. Output the odd numbers below the diagonal. 7. Output the even numbers above the diagonal.

image text in transcribed

Instruction: Create a java program that generates elements (randomly from 10 - 50) of a 2-dimensional array (5x5) using the Random Class then perform the following: 1) Output the array elements 2) Output the sum of prime numbers in the array 3) Output the elements in the main diagonal. 4) Output the sum of the elements below the diagonal. 5) Output the sum of the elements above the diagonal. 6) Output the odd numbers below the diagonal. 7) Output the even numbers above the diagonal. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items in bold italic are generated, calculated and printed by the program): 1) Output the array elements 21 30 33 45 32 50 10 50 35 42 25 12 35 12 11 45 14 50 28 21 15 41 15 19 41 2) Output the sum of prime numbers in the array. 112 3) Output the elements in the main diagonal. 21 10 35 28 41 4) Output the sum of the elements below the diagonal. 286 5) Output the sum of the elements above the diagonal. 311 6) Output the odd numbers below the diagonal. 25 45 15 41 19 7) Output the even numbers above the diagonal. 30 32 50 42 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

The sume of two odd integer is an even integer

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago