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
Ivanshal [37]
3 years ago
13

Write a program, TwoDimentionalGrid. Ask the user to enter the size of the 2 dimensional array. Here we are not doing any input

validation. We are assuming, user is going to enter a number greater than 1. Create a 2D array with the same row and column number. Now print the array as a number grid starting at 1. Example: At place row number 3 and column number 2, number would be 6 (3*2). Any number would be the product of it's row number and column number. Hint: Use setw 5. Expected Output: Here I am attaching 2 expected output. Make sure your code is running for both input.
Computers and Technology
1 answer:
Nitella [24]3 years ago
4 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Array size: ");

 int n = input.nextInt();

 int[][] myarray = new int[n][n];

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

     for(int j =0;j<n;j++){

         myarray[i][j] = i * j;      }  }

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

     for(int j =0;j<n;j++){

         System.out.print(myarray[i][j]+" ");      }

     System.out.println();  }

}}

Explanation:

This prompts the user for the array size

 System.out.print("Array size: ");

This gets input for the array size

 int n = input.nextInt();

This declares the array

 int[][] myarray = new int[n][n];

This iterates through the rows

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

This iterates through the columns

     for(int j =0;j<n;j++){

This populates the array by multiplying the row and column

         myarray[i][j] = i * j;      }  }

This iterates through the rows

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

This iterates through the columns

     for(int j =0;j<n;j++){

This prints each array element

        System.out.print(myarray[i][j]+" ");      }

This prints a new line at the end of each row

     System.out.println();  }

}

You might be interested in
What panel in the unity Editor shows the objects in the scene
Neporo4naja [7]

Answer:

A. The Hierarchy

Explanation:

The console tells you if there are any errors

The inspector shows you settings for one object

The project is the whole thing

7 0
4 years ago
Easy Bib and Cite This For Me are examples of online
motikmotik
The answer is:  [A]:  "bibliographic generators" .
____________________________________________________
5 0
3 years ago
¿en minimo cuantos computadores se puede construir una red,y en maximos en cuanto y que se necesita para que este en la red?​
stira [4]

Answer:

me no speak taco bell

Explanation:

3 0
3 years ago
When I’m design view, Henrietta deleted a previous criterion, added a new column, and filtered patients’ age. Which best describ
BaLLatris [955]

Answer:

Explanation:

b

8 0
3 years ago
A chemical found in the synaptic vesicles , which , when released . has an effect on the next cell is called a?
ruslelena [56]
Neurotransmitters is the chemical found in the synaptic vesicles that, when released, has an effect on the next cell.
7 0
4 years ago
Other questions:
  • Give a big-O estimate for the number of comparisons used by the algorithm that determines the number of 1s in a bit string of le
    9·2 answers
  • Why are networked systems beneficial?
    9·2 answers
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • The manufacturer doesn't need it the buyer doesn't want it the user doesn't know they're using it
    6·1 answer
  • To find and engage in Twitter conversations happening in specific geographical areas that are relevant to your company, you shou
    6·1 answer
  • To add a row labeled "total" to a query design click the ____ button in the show/hide group on the design tab on the ribbon.
    14·2 answers
  • In excel what is the biggest disadvantage of copying a worksheet into another workbook?
    15·1 answer
  • QuickBooks Online (QBCU) Session 4: Post Assessme
    12·1 answer
  • Suppose you have the following declaration.char[] nameList = new char[100];Which of the following range is valid for the index o
    7·1 answer
  • Explain why this scenario could put an organization in jeopardy of losing some of its workforce.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!