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
xz_007 [3.2K]
2 years ago
9

Read one positive integer n. Then create an n X n two-dimensional array and write the code that stores integers from 1 to n2 as

follows. Print the array using System.out.printf statement.
Enter the size of the array : 1 Enter the size of the array : 2
1 1 2
4 3
Enter the size of the array : 10
Enter the size of the array : 7 1 2 3 4 5 6 7 8 9 10
---------------------------------------- 20 19 18 17 16 15 14 13 12 11
---------------------------------------- 21 22 23 24 25 26 27 28 29 30
1 2 3 4 5 6 7 40 39 38 37 36 35 34 33 32 31
14 13 12 11 10 9 8 41 42 43 44 45 46 47 48 49 50
15 16 17 18 19 20 21 60 59 58 57 56 55 54 53 52 51
28 27 26 25 24 23 22 61 62 63 64 65 66 67 68 69 70
29 30 31 32 33 34 35 80 79 78 77 76 75 74 73 72 71
42 41 40 39 38 37 36 81 82 83 84 85 86 87 88 89 90
43 44 45 46 47 48 49 100 99 98 97 96 95 94 93 92 91
Computers and Technology
1 answer:
marysya [2.9K]2 years ago
8 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

    int n;

    Scanner input = new Scanner(System.in);

 System.out.print("Size of array: ");

 n = input.nextInt();

 int count = 1;

 int[][] arr = new int[n][n];

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

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

         arr[i][j] = count;

         count++;      }  }

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

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

         System.out.printf(arr[i][j]+" ");      }

     System.out.println();  } }}

Explanation:

This declares the size of the array

    int n;

    Scanner input = new Scanner(System.in);

This prompts the user for size of array

 System.out.print("Size of array: ");

This gets input for size of array

 n = input.nextInt();

This initializes the array element to 1

 int count = 1;

This creates a 2d array

 int[][] arr = 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

         arr[i][j] = count;

         count++;      }  }

The following nested loop prints the array elements

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

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

         System.out.printf(arr[i][j]+" ");      }

     System.out.println();  } }}

You might be interested in
Which of the following is not a technology that can be used to conserve resources?
amm1812
<span>Natural gas when extracted through human industry will utilise resources to construct the necessary plant and machinery and then result in the consumption of a resource. Therefore this is the technology that cannot be seen as conserving resources.</span>
6 0
3 years ago
Read 2 more answers
Addition and subtraction are considered to be ____ operations performed by a computer.
Natali5045456 [20]

Answer:

Mathematical operations

4 0
3 years ago
A(n) _________ produces dynamic reports, supports alerts/rss functionality, and supports user subscriptions.
lesantik [10]

A(n) BI server produces dynamic reports, supports alerts/RSS functionality, and supports user subscriptions.

<h3>What exactly is BI server?</h3>

An on-premises report server with a web gateway, Power BI Report Server allows you to see and manage reports and KPIs. The tools for generating Power BI reports, paginated reports, mobile reports, and KPIs are also included. A business intelligence server created by Oracle is called Oracle Business Intelligence Enterprise Edition. It has sophisticated business intelligence capabilities that are based on a single architecture. The server offers centralized data access to all corporate entity-related business information.

There are five stages to query compilation in BI server:

  • Parsing
  • Create Logical Requests
  • Navigation
  • Code Generation Rewrite

To learn more about BI server , refer to:

brainly.com/question/7601044

#SPJ4

7 0
1 year ago
Inaccurate __________ is the number-one reason why many small businesses go bankrupt.
givi [52]

Answer:

Option B

Explanation:

The top most reason for the bankruptcy of many small businesses is the inaccurate credit management.

Credit management deals with granting credits, recovery of credit granted on its due time,  terms of grant of credits, other related issues and to make sure it comply with the company's policies.

The main aim of credit management is to work for the improvement of profits generated and the revenues within a bank or a firm.

Therefore, any inaccuracy in these will result in major set back to many small businesses.

4 0
3 years ago
Pasahot ako plzsss kailangan ko na ngayon ​
goldfiish [28.3K]

Answer:

what language is this

Explanation:

3 0
2 years ago
Other questions:
  • A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
    13·1 answer
  • What task did the u.s. government undertake that many people identify as the birth of the internet
    5·2 answers
  • You are applying for a secretary position. You have many skills but which of the following would not be one to include on the ap
    12·2 answers
  • Select the characteristics that describe the evolution of computers that predate the personal computer (select all correct answe
    12·1 answer
  • Your baby brother has found the hammer and is eagerly eyeing one of the boxes. Describe and analyze an algorithm to determine if
    15·1 answer
  • Write a simple hello world program in python 3
    8·2 answers
  • How do you change the order of the slides in your presentation in the slide pane 
    15·2 answers
  • Focusing on the general characteristics of a problem or object, while ignoring the details, is a technique called
    15·1 answer
  • If you feel your friend had a negative digital identity, what would you do or tell them in order to help them have a positive di
    11·2 answers
  • Explain the integer and float datatypes with example.<br><br>​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!