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
Ratling [72]
2 years ago
6

Write a public static method diagSum, which takes a 2d array of int values as a parameter, and returns the sum of the elements i

n the lead diagonal as an int value. The lead diagonal is defined as the diagonal line of values starting in the top left corner and proceeding one step right and down for each value until either the bottom or right edge of the array is reached. For example, in the array represented below, the numbers in red make up the lead diagonal
Computers and Technology
1 answer:
saveliy_v [14]2 years ago
6 0

A 2d array (i.e. 2 dimensional array) represents its elements in rows and columns

<h3>The program in Java</h3>

The method in Java, where comments are used to explain each line is as follows

//This defines the method

public static int diagSum(int[][] myArray) {

    //This initializes sum to 0

    int sum = 0;

    //This iterates through each row of the array

               for (int i = 0; i < myArray.length; i++) {

                   //This calculates the sum of the diagonals

                       sum+=myArray[i][i];

               }

               //This returns the sum

               return sum;

       }

Read more about methods at:

brainly.com/question/15969952

You might be interested in
Computer design replaced ______________
bazaltina [42]
<span>Computer design replaced (B) models draw or created by hand. Technology nowadays has a big contribution in terms of planning and designing a building or a structure without burning your eyebrow facing that paper and handling your pen. Computer designs are used to make the design more accurate and more precise compared to traditional hand drawn designs.</span>
8 0
3 years ago
What is the Windows command to see the IP configuration of the PC?
lisov135 [29]
The answer is ipconfig
4 0
3 years ago
Taking a recipe and breaking it down into its individual sections, like ingredients, preparation, cooking instructions, and nutr
Anna11 [10]
1.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element that reacts with water to produce a lilac flame

2.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element used as an inert atmosphere

3.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element that has a valency of 3

4.Write a balanced chemical equation for the reaction between potassium and water. (Non-anonymous question). .
(1 Point)

Upload file
File number limit: 1Single file size limit: 10MBAllowed file types: Word, Excel, PPT, PDF, Image, Video, Audio
5.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element with a fixed valency of 2 that not is not in group 2
8 0
3 years ago
Read 2 more answers
Which appears at the intersection of a column and row?
Evgesh-ka [11]
Between the intersection between every column and row is a cell.
6 0
2 years ago
2. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The object
laiz [17]

Answer:

The Python code is given below with appropriate comments

Explanation:

#required method, assuming Volume class is defined and is accessible

def partyVolume(filename):

   #opening file in read mode, assuming file exists

   file=open(filename,'r')

   #reading initial volume

   initial=float(file.readline())

   #creating a Volume object with initial volume

   v=Volume(initial)

   #looping through rest of the lines in file

   for line in file.readlines():

       #removing trailing/leading white spaces/newlines and splitting line by white

       #space to get a list of tokens

       line=line.strip().split(' ')

       #ensuring that length of resultant list is 2

       if len(line)==2:

           #reading first value as direction (U or D)

           dir=line[0].upper()

           #reading second value as float value

           value=float(line[1])

           if dir=='U':

               #turning volume up

               v.up(value)

           elif dir=='D':

               #turning volume down

               v.down(value)

   #closing file, saving changes

   file.close()

   #returning volume

   return v

8 0
3 years ago
Other questions:
  • Which reading strategy refers to reading only the key words and phrases?
    13·2 answers
  • A text-only forum accessed through a bulletin board service (BBS) is known as a _____.
    14·1 answer
  • Microsoft Windows is the least used operating system. TRUE or FALSE.
    13·1 answer
  • A network consists of 10 computers, all running windows 7 professional. one computer acts as a file server and serves up data to
    6·1 answer
  • Ethics is a way of behaving so that you are
    7·2 answers
  • How do you change the Background image or picture on Windows desktop?
    9·1 answer
  • One friend claims that a dual-core system runs at twice the speed as a single-core system; another friend disagrees by saying th
    13·1 answer
  • Is it good to work out at the gym one day with hands then the next with feet, then a pattern?
    11·2 answers
  • Imagine that you need to prepare for three end-of-term tests. What steps will you take to make sure your study time is well spen
    5·1 answer
  • What technology does kroger’s edge technology and amazon’s just walk out technology leverage?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!