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
pshichka [43]
3 years ago
5

Write a Java program that will be able to generate the sample table below.

Computers and Technology
1 answer:
Gwar [14]3 years ago
7 0

Answer:

class Main {

 public static void fillTable(int [][] t, int or, int oc) {        

   for(int r=0; r<t.length; r++) {

     for(int c=0; c<t[r].length; c++) {

         t[r][c] = Math.max(1+Math.abs(r-or), 1+Math.abs(c-oc));

       }

   }

 }

 public static void dumpTable(int [][] t) {

   for(int r=0; r<t.length; r++) {

     for(int c=0; c<t[r].length; c++) {

       System.out.printf("%3d", t[r][c]);

     }

     System.out.println();

   }

 }

 public static void main(String[] args) {

   int origin_row = 3;

   int origin_col = 2;

   

   int[][] table = new int[5][4]; // rows|cols

   fillTable(table, origin_row, origin_col);

   dumpTable(table);

   

 }

}

Explanation:

Above program does not contain input handling and exception handling, but it does contain the cleverness of calculating the cell values. I'm hoping you can add the input handling yourself?

You might be interested in
An IP packet to be transmitted by Ethernet is 60 bytes long, including all its headers. If LLC is not in use, is padding needed
salantis [7]

Answer:

No padding

Explanation:

64 bytes is taken as the minimum Ethernet frame, this encompass checksum as well as addresses in the Ethernet frame header and length field. while the maximum Ethernet frame is 1518 bytes, any minimumEthernet frame that is short compare to that will need receiving stations to interpret it as a collision. The question specified that the IP packet to be transmitted by Ethernet as 60 bytes long. The header fields here can occupy 18 bytes, Then total frame size becomes 78 bytes. With the total frame size of 78 bytes(60 bytes+ 18 bytes) we can see it has exceeded the 64-byte minimum. Hence there is no padding used.

6 0
3 years ago
What is the purpose of a register in a CPU? Describe three types of registers.
Ganezh [65]

Answer:

I hope this answer is correct

Explanation:

Internal registers include the instruction register (IR), memory buffer register (MBR), memory data register (MDR), and memory address register (MAR). The instruction register fetches instructions from the program counter (PC) and holds each instruction as it is executed by the processor.

5 0
3 years ago
Always refill your gas tank well before____.
mash [69]

Aloha~. My name is Zalgo and I am here to be of assistance with your problem. The answer to your question is D. The minimum amount of gas you can leave in your vehicle is 1/4 Full or 3/4 Empty. The most amount you will need is quite close to when your gas tank is full (so 1/4 Empty or 3/4 Full).

Hope this helps.

"Stay Brainly and stay proud!" - Zalgo

4 0
3 years ago
Read 2 more answers
Which letter would appear in the third position of the standard wheel marking of a hard-grade wheel?
torisob [31]
B is the correct answer you are looking for 

6 0
3 years ago
Read 2 more answers
What is the missing line of code?
nlexa [21]

Answer:

books.keys()

Explanation:

I ran the code and the awncers though python and books.keys() is the one that came up with the awncer

3 0
3 years ago
Other questions:
  • Briefly describe the significance of the shannon limit for information capacity.
    5·1 answer
  • For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are
    15·2 answers
  • A 5.5 g sample of a substance contains only carbon and oxygen. Carbon makes up 35% of the mass of the substance. The rest is mad
    8·1 answer
  • What does the metric column in a routing table do?
    8·1 answer
  • 13) What are the benefits and detriments of each of the following? Consider both the systems and the programmers’ levels. a. Sym
    14·1 answer
  • Movie recommendations? I’m in middle school so nothing nasty bro and I don’t really like horror movies so none of those either
    13·2 answers
  • Which formula uses relative cell references? $A$10/100 5*10+20 F18+F19/2 $B$5+30
    6·1 answer
  • Which is one use for a hyperlink? A. to create a heading style B. to animate important text C. to create a link to a website. D.
    7·1 answer
  • Which statement describes the Direction option for animations and transitions?
    5·2 answers
  • For (int j- 4; j &gt; 0; j--)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!