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]
2 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]2 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
Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
SpyIntel [72]
<span>Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of rewards for doing well in school. As the result of doing well in studies, a person can hang out with friends, watch their own favorite TV show and can buy a new pair of shoes. Hence all these things are the rewards that are being generated for a good performance in school.</span>
8 0
3 years ago
Read 2 more answers
Mr. Yang is a doctor who regards video games as an effective means of staying fit. What type of game would he recommend to his p
morpeh [17]

Answer:

D. An exergame

Explanation:

It is because the exercise game is the suitable game to staying fit. For example wii video game able to give the similar experience to outdoor activities such as playing tennis, kick boxing etc.

8 0
3 years ago
Read 2 more answers
Discuss what repetitions structures are, and how they differ from the vectorization approaches we have previously studied in the
gogolik [260]

Repetition structures, or loops, are used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends. Many programming tasks are repetitive, having little variation from one item to the next. Vectorized mathematical code appears more like the mathematical expressions found in textbooks, making the code easier to understand. That is the difference. Hope I could help you on Brainly.com!

6 0
3 years ago
Why is it useful for students to practice the MLA and APA citation methods?
notka56 [123]

Answer:

Citing or documenting the sources used in your research serves three purposes:

It gives proper credit to the authors of the words or ideas that you incorporated into your paper.

It allows those who are reading your work to locate your sources, in order to learn more about the ideas that you include in your paper.

5 0
2 years ago
Technical skills are also called soft skills.<br> Question 9 options:<br> True<br> False
mestny [16]

The statement is false, technical skills are those that serve to perform a specific function and are also called hard skills.

Technical skills are skills that include knowledge in the mechanical, computer, mathematical or scientific area that will allow a good performance of specific tasks.

  • A person with technical or hard skills is able to apply specific methods, procedures and techniques in a specialized field.

  • Soft skills refers to the characteristics and personal competencies that show how a person copes with others, it is related to emotional intelligence.

Therefore, we can conclude that technical or hard skills are the practical knowledge necessary to perform specific tasks, while soft skills are those skills associated with the ability to interact effectively on a personal level.

Learn more about technical skills here: brainly.com/question/10976877

8 0
2 years ago
Other questions:
  • Please answer fast screenshot included - thanks in advance
    11·1 answer
  • "Once a business operations analysis is completed and change needs to
    7·2 answers
  • What information is displayed in the title bar?
    10·1 answer
  • You buy a new workstation that features an embedded RAID controller on the motherboard. You want to setup hardware RAID 10. How
    10·2 answers
  • Edhesive Intro to cs quiz 2 q#9 <br><br> What is output? <br> Print (3 % 15)<br> Thanks!!
    8·1 answer
  • What is a Computer ?and it's demerits​
    13·2 answers
  • Write python code that does the following: Ask the user to enter as many as number they want; Then find the sum and the average
    10·1 answer
  • What does the following Boolean operators do?<br>AND function<br>OR function<br>NOT function​
    8·1 answer
  • Compiler is an example of​
    5·1 answer
  • the human resources department requests a list that contains the number (i.e. count) of orders taken on each date, grouped by th
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!