1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
katrin2010 [14]
3 years ago
7

Write a Java program that creates a two-dimensional array of type integer of size x by y (x and y must be entered by the user).

The program must fill the array with random numbers from 1 to 9. Then, the program must print the original array and the elements that are in even columns of the array.
Computers and Technology
1 answer:
Law Incorporation [45]3 years ago
3 0

Answer:

The java program is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 Random r = new Random();

 int x, y;

 x = input.nextInt();  

 y = input.nextInt();

 int[][] Array2D = new int[x][y];

 for(int i = 0; i < x ; i++){

     for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }

 }

 for(int i = 0; i < x ; i++){

     for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

 

 for(int i = 0; i < x ; i++){

     for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

}

}

Explanation:

This creates a random object

 Random r = new Random();

This declares x and y as integers

 int x, y;

This gets input for x

 x = input.nextInt();  

This gets input for y

 y = input.nextInt();

This declares the 2D array

 int[][] Array2D = new int[x][y];

The following iteration populates the array with integers 1 to 9

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }</em>

<em>  }</em>

The following iteration prints all elements of the array

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

The following iteration prints all elements on the even column

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

<em />

You might be interested in
When workers use techology to work from home or an office center, they are
dem82 [27]

Answer:

Electronically

Explanation:

Hope this helps

8 0
3 years ago
Read 2 more answers
Please help me with this question<br>it on the picture​
erik [133]

Explanation:

2)computer is a general process machine ,commonly constitution for Digital circuits that accept input stores manipulated and generates output.

example of input:

monitor ,speaker,printer etc.

example of output:

keyboard,cpu,mouse etc.

3 0
3 years ago
In this​ video, Samir describes how business executives use a BI application to drill down and see​ _____ data, the detail in th
Zielflug [23.3K]

Answer and Explanation:

The answer is granular data.

Granular data is detailed data. As granular data is lowest level data, that can refer to the size as Granularity is the level of detail where data are stored in the database. For example, a table contains cost attributes but in both table cost to use for different columns and different purpose.

The other example of granular data is the name field is subdivided. Such as

First name, middle name, and last name.

Data becomes specific and conferred as more granular.

5 0
4 years ago
In Rizzati Corp, vice presidents in departments such as engineering, manufacturing, IT, and human resources report directly to t
Harrizon [31]

Answer: <em>Functional organizational structure.</em>

Explanation:

From the given case/scenario, we can state that Rizzati Corp has a functional organizational structure. Functional organizational structure is referred to as a structure which is used in order to organize employees. The employees are mostly grouped or organized based on their knowledge or specific skills. It tends to vertically structure each and every department or staff with specific roles from VP to sales and finance departments, to worker assigned to commodities or services.

7 0
3 years ago
Your company collects and stores security camera footage. Within the first 30 days, footage is processed regularly for threat de
Sliva [168]

Answer:

<em>For the very first 30 days, use Google Cloud Regional Storage, then switch to Coldline Storage.</em>

Explanation:

Coldline Storage is a cost-effective, extremely durable information archiving, online backup, and disaster recovery web host.

Your information is available in seconds, not hours or days, unlike many other "cold" storage providers.

5 0
4 years ago
Other questions:
  • Guidelines:
    6·1 answer
  • How is an interpreter different from a compiler?
    6·2 answers
  • If you are working on a document and want to have Word automatically save the document every minute, what steps should you use t
    13·1 answer
  • Cell A1 contains the formula "=10+D2". If you copied A1 to B3, what would be the formula in B3?
    10·2 answers
  • Your customer asks you if it would be worth the investment for him to have Ethernet cabling installed to reach each of his works
    6·1 answer
  • a rule that states each foreign key value must match a primary key value in the other relation is called the
    5·1 answer
  • 19 dollar fortnite giftcard who wants it
    15·2 answers
  • Create an array class consisting of a static array of three elements, and describe it in such a way that the Point and Vector cl
    8·1 answer
  • Draw a flowchart diagram for a program that displays numbers 1 to 20
    12·1 answer
  • When developing an output control system, it is important to implement output standards that: (Choose all that apply.)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!