Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

problem1:Write Java program as follows: a .Declare integer 2D array with 5 rows and 5 columns. b. Initialize the array elements to random integers between

problem1:Write Java program as follows:

a.Declare integer 2D array with 5 rows and 5 columns.

b.Initialize the array elements to random integers between 1 and 9.

c. Perform the tasks given below.

i.Display all the elements in the 2D array as a table of rows and columns.

ii.Display all the diagonal elements (the elements where row index and column index are same)

iii.Find the minimum of the first row.

iv.Find the maximum of the third column.

Use following statement to get the integer random numbers between 1-9.

int r = (int) (Math.random()*(9-1+1)) + 1;

problem2:

Write a Java program that reads 5 integers from the user and stores them in a 1D integer array. Then display the value stored in each element using a bar chart. For example, if user input 2,5,3,8 and 4 as the input values your program should display the bar chart as follows.

* *

* * * * *

* *

*

* * * * * * * *

* * * *

The steps for this program can be given as follows:

1.Declare and initialize integer array (say data) with 5 elements.

2.Take 5 integers from user and store in the data array. Use a loop statement.

3. Take each element from the data array and display asterisk marks. Use nested loop statement as follows:

for(int i=0; i<5; i++)

{

for(int j=0; j

{

System.out.print(* + \t);

}

System.out.print( );

}

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions