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
Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, pr
anastassius [24]

Well, you didn't say what language, so here's in Java:


public static void PrintShampooInstructions(int numCycles)

   {

       if(numCycles < 1)

           System.out.println("Too few.");

       else if (numCycles > 4)

           System.out.println("Too many.");

       else

       {

           for(int i = 1; i <= numCycles; i++)

           {

               System.out.println(i+": Lather and rinse.");

           }

           System.out.println("Done.");

       }

   }


And also in an image, in case you can't really see it

6 0
3 years ago
Read 2 more answers
Which can be used to enter and manipulate information in a database?<br><br> ANSWER: C) a form
alexgriva [62]

Answer:

a form

Explanation:

it says the answer already in the question

3 0
4 years ago
How does speech recognition software know what you are saying?
boyakko [2]
It converts the mic input into a string of raw data, then compares it to hundreds, even thousands of voice samples. The output is a polished string of data in words.
8 0
4 years ago
___________ is a technique that uses IT to develop an ongoing relationship with the purchasers or buyers of an organization's pr
Diano4ka-milaya [45]

Answer:

Customer relationship management.

Explanation:

Customer Relationship Management provides the controls overall the relationships of business between the clients and potential customers to getting the profit in the business The main objective of Customer Relationship Management is to enhance the relationships between businesses.  

Customer Relationship Management builds the ongoing partnership with the purchasers or purchasers of the commodity of an organization to optimize the value that the company can offer over time.

5 0
3 years ago
Which of the following statements applies to a proprietary software license? a. Purchased from a vendor and gives you the right
Semmy [17]

Answer: a)Purchased from a vendor and gives you the right to use the software but is not yours to own.

Explanation: Proprietary software is the software that can be used by the user but it has  copyright of the vendor/holder in any case.There are some certain condition under which the user can use this software.The distribution of the software is not permitted in this case. No modification or manipulation can be done by the user.

Other options are incorrect because it is not free as its purchased from vendor ,not freely available rather guided by owner and can be used over certain period of time.Thus , the correct option is option(a).

3 0
3 years ago
Other questions:
  • Explain and Define the four types of maintenance in IT?
    11·1 answer
  • You are capturing packets with a network sniffer and notice a number of packets that are flagged by the sniffer and described as
    5·1 answer
  • Which of the following best supports the utilization of environmental engineers on a civil engineering hydraulic project?
    13·1 answer
  • To complete this quest, answer the following questions in the submission box below. Make x an array going from 0 to 100 by steps
    15·1 answer
  • To type a small letter "z", you would use the right little finger. (5 points)True False
    9·1 answer
  • What are the diffrent types of contract
    9·1 answer
  • Romans are credited with “inventing” the capital city l? T or F
    6·1 answer
  • Select all the correct answers.
    15·1 answer
  • Write down the stages in the information prcessing cycle in correct order​
    5·1 answer
  • How to print something nad input on same line python
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!