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
Why is a class called a factory of objects
zhenek [66]

Explanation:

A class is called an object factory because objects are created from a class. An object is an instance of a class.

4 0
3 years ago
To discover how many cells in a range contain values that meet a single criterion, use the ___ function
alexandr402 [8]

Answer:

COUNTIF

Explanation:

the Countif function counts the number of cells in range that meets a given criteria.

6 0
2 years ago
When pointed over a text within a paragraph, the cursor takes the shape of a/an
Crank
I type of shape, or a pointing index finger
5 0
3 years ago
What new england industry quickly collapsed with the discovery of oil in pennsylvania
Elena-2011 [213]

It was the whaling industry.  Whaling use to be the main source of oil that was used for fuel and lighting in America which was based in the coastal communities of New England.  It went into decline when oil was discovered in 1859.  Eventually it replaced whale oil as a source of fuel and life.

6 0
3 years ago
Read 2 more answers
In 1-2 sentences, describe how to use the thesaurus in the Word Processor you have used.
jasenka [17]
Thesaurus is a tool use to find the synonym of the of a word.
Here's the way to use the thesaurus in the word processor.
=> highlight the word, then right-click, Navigate to synonyms and the words will  display.
3 0
3 years ago
Read 2 more answers
Other questions:
  • What is a nonlinear presentation
    9·2 answers
  • Host A and B are directly connected with a 100 Mbps link. There is one TCP connection between the two hosts, and Host A is sendi
    14·1 answer
  • Where is authorization management app on tablet?
    7·1 answer
  • Why is it so important that you know how much traffic dfs replication requires?
    13·2 answers
  • Which one of the following is NOT true about energy conversion devices? Group of answer choices Total Energy Input = Energy Diss
    8·1 answer
  • 6. A distribution consists of three components with frequencies 200, 250 and 300 having means
    14·1 answer
  • I'd like to edit a picture so that I can remove the background behind an object and have it replaced with a transparent backgrou
    13·2 answers
  • If an author is creating a reference list and wants the second and succeeding lines indented for a reference, they should select
    13·2 answers
  • Briefly describe the traditional definition of the digital divide. What is it and who is affected, positively and adversely? How
    15·1 answer
  • Meaning and explanation of fortran​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!