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]
2 years ago
5

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

Computers and Technology
1 answer:
Gwar [14]2 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
a. Do you think the U.S. government should censor information on the Web, such as instructions for making weapons, to protect th
MrRissso [65]

Answer:

The answer is YES.

Explanation:

<em>Things pertaining to weapons, destructive materials should be shared with precautions or much better if these things should not be put online. Since internet is widely available to almost all types of users and almost to all places, we cannot be sure of who will get hold of these information. Kids could easily see this and gain knowledge and out of curiosity will try these dangerous things. Terrorist groups will also have access to these information and who knows might happen to poor innocent souls around.  </em>

<em> </em>

<em>I don't think it would violate the right of First Amendment regarding freedom of speech. Freedom should be granted on matters that are most sensible. And this time, we are just protecting the rights of children and other innocent people who can be a victim including you. We are talking about weapons and destructive materials here which is non beneficial if one could get hold of this information, in my opinion. If there is really a need to construct these things, it is better to consult an expert or an authority to ensure that nobody gets harm.</em>  

5 0
3 years ago
What is the python print of (“5”+”7”)?
Firdavs [7]

Answer:

57

Explanation:

Since the 5 and the 7 don't represent integers instead they represent strings so it would come out as 57 hope I helped!

4 0
3 years ago
Two machines can finish a job in StartFraction 20 Over 9 EndFraction hours. Working​ alone, one machine would take one hour long
Alborosie

<em><u>Answer</u></em>

5 hours

<em><u>Explanation</u></em>

The two working together can finish a job in

\frac{20}{9}  \: hours

Also, working alone, one machine would take one hour longer than the other to complete the same job.

Let the slower machine working alone take x hours. Then the faster machine takes x-1 hours to complete the same task working alone.

Their combined rate in terms of x is

\frac{1}{x}    +  \frac{1}{x - 1}

This should be equal to 20/9 hours.

\frac{1}{x}  +  \frac{1}{x - 1}  =  \frac{9}{20}

Multiply through by;

20x(x - 1) \times \frac{1}{x}  +20x(x - 1) \times   \frac{1}{x - 1}  =  20x(x - 1) \times \frac{9}{0}

20(x - 1)  +20x = 9x(x - 1)

20x - 20+20x = 9{x}^{2}  - 9x

9{x}^{2}  - 9x - 20x - 20x + 20= 0

9{x}^{2}  - 49x  + 20= 0

Factor to get:

(9x - 4)(x - 5) = 0

x =  \frac{4}{9}  \: or \: x = 5

It is not feasible for the slower machine to complete the work alone in 4/9 hours if the two will finish in 20/9 hours.

Therefore the slower finish in 5 hours.

8 0
3 years ago
What type of maintenance can prevent the computer from breaking?
qwelly [4]
<span>The answer is, "Load anti-virus software".
</span>Anti-virus softwares are used to prevent computer from virus, as it name shows that are anti-virus means they prevent from virus. Anti virus softwares are also known as anti-malware software. These software work in such a way that they <span>prevent, detect and then remove viruses or </span><span>malicious software.</span>
3 0
3 years ago
Read 2 more answers
Which of these is an example of gathering secondary data?
Soloha48 [4]

Answer:

searching for a chart

Explanation:

:)

7 0
3 years ago
Other questions:
  • An OS X backup utility that automatically backs up files to a dedicated drive that is always available when the computer is turn
    6·1 answer
  • Technologies are having a negative impact on businesses.
    8·1 answer
  • It is possible to limit the search results to a range of publication dates.
    13·1 answer
  • kieran wants to search a database quickly for information on the last time a patient came to his medical facility.The informatio
    14·2 answers
  • A cover letter should simply restate what is included in your résumé.<br> True<br> False
    7·2 answers
  • Where do i put the lines?
    11·1 answer
  • Rosa is building a website for a multimedia company. She wants to add a drop-down menu functionality to the website's main page.
    12·1 answer
  • What are the top 10 most dangerous computer viruses ?
    13·1 answer
  • If an if-else statement is true, it will include which kinds of results?
    13·1 answer
  • If a person communicates indirectly and attaches little value to
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!