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
nlexa [21]
3 years ago
11

Given an array as follows

Computers and Technology
1 answer:
slava [35]3 years ago
5 0

Answer:

1) Method calcTotal:

  1. public static long calcTotal(long [][] arr2D){
  2.        long total = 0;
  3.        
  4.        for(int i = 0; i < arr2D.length; i++ )
  5.        {
  6.            for(int j = 0; j < arr2D[i].length; j++)
  7.            {
  8.                total = total + arr2D[i][j];
  9.            }
  10.        }
  11.        
  12.        return total;
  13.    }

Explanation:

Line 1: Define a public method <em>calcTotal</em> and this method accept a two-dimensional array

Line 2: Declare a variable, total, and initialize it with zero.

Line 4: An outer for-loop to iterate through every rows of the two-dimensional array

Line 6: An inner  for-loop to iterate though every columns within a particular row.

Line 8: Within the inner for-loop, use current row and column index, i and j, to repeatedly extract the value of each element in the array and add it to the variable total.

Line 12: Return the final total of all the element values as an output

Answer:

2) Method calcAverage:

  1. public static double calcAverage(long [][] arr2D){
  2.        double total = 0;
  3.        int count = 0;
  4.        
  5.        for(int i = 0; i < arr2D.length; i++ )
  6.        {
  7.            for(int j = 0; j < arr2D[i].length; j++)
  8.            {
  9.                total = total + arr2D[i][j];
  10.                count++;
  11.            }
  12.            
  13.        }
  14.        
  15.        double average = total / count;
  16.        
  17.        return average;
  18.    }

Explanation:

The code in method <em>calcAverage</em> is quite similar to method <em>calcTotal</em>. We just need to add a counter and use that counter as a divisor of total values to obtain an average.

Line 4: Declare a variable, count, as an counter and initialize it to zero.

Line 11: Whenever an element of the 2D array is added to the total, the count is incremented by one. By doing so, we can get the total number of elements that exist in the array.

Line 16: Use the count as a divisor to the total to get average

Line 18: Return the average of all the values in the array as an output.

Answer:

3) calcRowAverage:

  1. public static double calcRowAverage(long [][] arr2D, int row){
  2.        double total = 0;
  3.        int count = 0;
  4.        
  5.        for(int i = 0; i < arr2D.length; i++ )
  6.        {
  7.            if(i == row)
  8.            {
  9.                for(int j = 0; j < arr2D[i].length; j++)
  10.                {
  11.                    total = total + arr2D[i][j];
  12.                    count++;
  13.                }
  14.            }
  15.            
  16.        }
  17.        
  18.        double average = total / count;
  19.        
  20.        return average;
  21.    }

Explanation:

By using method <em>calcAverage </em>as a foundation, add one more parameter, row, in the method <em>calcRowAverage</em>. The row number is used as an conditional checking criteria to ensure only that particular row of elements will be summed up and divided by the counter to get an average of that row.

Line 1: Add one more parameter, row,

Line 8-15: Check if current row index, i, is equal to the target row number, proceed to sum up the array element in that particular row and increment the counter.

You might be interested in
Which of the following protocols allows seemingly ill-matched computers to communicate with one another?
hodyreva [135]

Answer:

HTTP

Explanation:

HTTP is Hyper Text Transfer Protocol. This protocol is used to provide connection between server and client that are not connected or ill-matched. When a client request to the website. this address facilitate the client to connect with the server that is not directly connected to the client computer.

As we know, every website address starts with http/:  

5 0
3 years ago
Once a manual is written, it may change over time as procedures change. What's a recommended format for a manual to incorporate
zhenek [66]

Answer:

Print the manual in a loose leaf binder so even small changes can be replaced

Explanation:

Procedure  manual is the document that contains the business policies and strategies. These strategies can be changed time to time in the interest of company.

As these policies or procedures changes, it is necessary to communicate with all employees. To communicate this updated information to all employees it is necessary to print all that pages, where the changes have been made to replace them in the current manual. If we print whole manual it may increase the cost of printing. To reduce printing cost and wastage of pages only print those particular pages that have been changed. This will help to communicate to the existing employees as well  as to newly hired employees.

3 0
3 years ago
While conducting a vulnerability assessment, you're given a set of documents representing the network's intended security config
Sophie [7]

Answer:

The baseline review

Explanation:

Solution:

The baseline review: this can be defined as the gap analysis or the beginning environmental review (IER). it is an assess study to get information about an organisation's present activities and associated environmental impacts,  impacts and legal requirements.

This review issues an overview of the quality and weaknesses of an organisation’s environmental execution and opportunities for improvement.

6 0
3 years ago
There has been something I had to ask but I have to type this so it goes through: creeper?
VMariaS [17]

Answer:

<u><em>awwwwwwwwwwwwwwwwwww man</em></u>

Explanation:

So we back in the mine

Got our pickaxe swinging from side to side

Side-side to side

This task, a grueling one

Hope to find some diamonds tonight, night, night

Diamonds tonight

Heads up

You hear a sound, turn around and look up

Total shock fills your body

Oh, no, it's you again

I can never forget those eyes, eyes, eyes

Eyes-eye-eyes

'Cause, baby, tonight

The creeper's tryna steal all our stuff again

'Cause, baby, tonight

You grab your pick, shovel, and bolt again (Bolt again-gain)

And run, run until it's done, done

Until the sun comes up in the morn'

'Cause, baby, tonight

The creeper's tryna steal all our stuff again (Stuff again-gain)

Just when you think you're safe

Overhear some hissing from right behind

Right-right behind

That's a nice life you have

Shame it's gotta end at this time, time, time

Time-time-time-time

[Pre-Chorus: TryHardNinja]

Blows up

Then your health bar drops and you could use a one-up

Get inside, don't be tardy

So, now you're stuck in there

Half a heart is left, but don't die, die, die

Die-die-die

'Cause, baby, tonight

The creeper's tryna steal all our stuff again

'Cause, baby, tonight

You grab your pick, shovel, and bolt again (Bolt again-gain)

And run, run until it's done, done

Until the sun comes up in the morn'

'Cause, baby, tonight

The creeper's tryna steal all our stuff again

(Creepers, you're mine, haha)

Dig up diamonds and craft those diamonds

And make some armor, get it, baby

Go and forge that like you so MLG pro

The sword's made of diamonds, so come at me, bro, huh

Training in your room under the torchlight

Hone that form to get you ready for the big fight

Every single day and the whole night

Creeper's out prowlin', hoo, alright

Look at me, look at you

Take my revenge, that's what I'm gonna do

I'm a warrior, baby, what else is new?

And my blade's gonna tear through you, bring it

'Cause, baby, tonight

The creeper's tryna steal all our stuff again

(Gather your stuff, yeah, let's take back the world)

Yeah, baby, tonight (Haha)

Grab your sword, armor and go (It's on)

Take your revenge (Woo), oh-oh, oh-oh

So fight, fight, like it's the last, last night

Of your life, life, show them your bite (Woo)

'Cause, baby, tonight

The creeper's tryna steal all our stuff again

'Cause, baby, tonight

You grab your pick, shovel and bolt again (Bolt again-gain, woo)

And run, run until it's done, done

Until the sun comes up in the morn'

'Cause, baby, tonight (Come on, swing your sword up high)

The creeper's tryna steal all our stuff again (Come on, jab your sword down low)

(Woo)

3 0
3 years ago
What are examples of common computer software problems?
MAXImum [283]

Movie Video Editor, Windows 10, Paint, MS Paint, Word Document, Spreadsheet, Calculator, Email, Hotmail, Google Chrome, Firefox, Internet Explorer, & more. Just some from the top of my head.

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the answer to this?
    9·1 answer
  • What is the process of publishing a work in Photoshop?
    5·1 answer
  • What is the best reason to delete Internet browsing history on a regular basis? to solve a computer hardware problem to protect
    13·2 answers
  • Why do contour lines never cross?
    5·1 answer
  • According to the Bureau of Labor Statistics, how
    14·1 answer
  • Zachary was frustrated. His computer was running very slowly and he was worried that it was reducing his productivity on the job
    15·1 answer
  • Write a program that include a method that returns the sum of all the elements of a Linked List of Integers. Allow the user to e
    11·1 answer
  • Which should be addressed by stakeholders when reviewing the problem statement? Select all that apply. All possible outcomes hav
    12·1 answer
  • Create an application that determines the final cost of food items and non-food items, assuming only non-food items are taxed. T
    8·1 answer
  • Subscribe too my you tube channel for a brainiest
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!