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
Kristen wants to view the records of her database in ascending order. What should she do?
Elanso [62]

the answer is Sort the table

6 0
3 years ago
Read 2 more answers
An employee in your company earns $32,500 annually. Write a program that determines and displays the amount of his/her gross pay
OverLord2011 [107]

Answer:

The reason for the error is that the pay is declared and initialized as double, which should be a larger float data type and the main function should be in curly braces. The class should best be declared and initialized before the main function.

Explanation:

class Fvp{

Fvp( double earning ){

  double pay = earning;

  float bimth = pay/24;

  float biweek = pay/26;

}

}

int main( ) {

  Fvp john(32500.00);

  cout << '' Annual earnings: $'' << john.pay << endl;

  cout << '' Bimonthly earnings: $'' << john.bimth << endl;

  cout << '' Biweekly earnings: $'' << john.biweek << endl;

}

8 0
3 years ago
5.Give an example of a situation in which ordinary pipes are more suitable than named pipes and an example of a situation in whi
rodikova [14]

The use of ordinary pipes is effective when you want to establish communication between two processes on the same machine. The use of named pipes is more suitable when you want to establish communication with a network.

<h3 /><h3>What is a pipe?</h3>

Corresponds to a unidirectional communication technique between processes with a common ancestor in Linux and UNIX operating systems. Each pipe is able to communicate by sending a sequence of bytes to the other system.

Therefore, to communicate with a network, it is necessary to use named pipes that are used for requests from other processes similar to TCP/IP ports.

Find out more information about computer programming here:

brainly.com/question/23275071

4 0
3 years ago
Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
Ksenya-84 [330]

Answer:

class Fighter(Spaceship):

   weapon = ""

   remain_fire_power = 5

Explanation:

The class "Fighter" is a python class that inherits all the variables and methods from the Spaceship class. The Fighter class is considered the child class while the Spaceship class is known as the parent class. The weapon and remain_fire_power variables are class variables unique to the fighter class and defaulted to an empty string and 5 respectively.

4 0
3 years ago
Which is an example of artificial intelligence in computers? A. multimedia software B. encryption software C. voice recognition
andrezito [222]

Answer:

its option b encryption software

Explanation:

Artificial intelligence (AI) is intelligence demonstrated by machines, unlike the natural intelligence displayed by humans and animals, which involves consciousness and emotionality. The distinction between the former and the latter categories is often revealed by the acronym chosen. 'Strong' AI is usually labelled as AGI (Artificial General Intelligence) while attempts to emulate 'natural' intelligence have been called ABI (Artificial Biological Intelligence). Leading AI textbooks define the field as the study of "intelligent agents": any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals.[3] Colloquially, the term "artificial intelligence" is often used to describe machines (or computers) that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem solving".

3 0
3 years ago
Other questions:
  • What are the only things that can be declared in an interface?
    11·1 answer
  • The this reference . a) can be used implicitly b) must be used implicitly c) must not be used implicitly d) must not be used 25)
    11·1 answer
  • We will pass in 2 values, X and Y. You should calculate XY XY and output only the final result. You will probably know that XY X
    13·1 answer
  • What is activated as necessary to support local eocs and to ensure that responders have the resources they need to conduct respo
    5·1 answer
  • If a firm's pages are not near the top of query results, customers may never discover its website. This has led to _____ becomin
    12·1 answer
  • Aapke question about computer keyboard​
    5·1 answer
  • Various units used to measure computer memory
    13·1 answer
  • What may happen if a large number of computer users are attempting to access a Web site at the same time that you are?
    5·2 answers
  • A collection of code makes up which of the following?
    14·2 answers
  • A digital presence created online by an individual or organization using a digital device is called a identity.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!