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
Gemiola [76]
3 years ago
5

In java I need help on this specific code for this lab.

Computers and Technology
1 answer:
rosijanka [135]3 years ago
8 0

Answer:

Explanation:

The following code is written in Java and creates the two methods as requested each returning the desired double[] array with the averages. Both have been tested as seen in the example below and output the correct output as per the example in the question. they simply need to be added to whatever code you want.

public static double[] rowAvg(int[][] array) {

       double result[] = new double[array.length];

     for (int x = 0; x < array.length; x++) {

         double average = 0;

         for (int y = 0; y < array[x].length; y++) {

             average += array[x][y];

         }

         average = average / array[x].length;

         result[x] = average;

     }

     return result;

   }

   public static double[] colAvg(int[][] array) {

       double result[] = new double[array[0].length];

       for (int x = 0; x < array[x].length; x++) {

           double average = 0;

           for (int y = 0; y < array.length; y++) {

               average += array[y][x];

           }

           average = average / array.length;

           result[x] = average;

       }

 

       return result;

   }

You might be interested in
1. Write a program to prompt the user to enter a single character and respond back whether or not the character is valid dna. 2.
Nina [5.8K]

Answer:

Answer 1:

dna = input("Enter DNA type: ")

dna = dna.upper()

print(dna)

if dna == "A" or dna == "B" or dna == "Z":

   print("valid")

else:

   print("invalid")

Answer 2:

rna = input("Enter DNA type: ")

rna = rna.lower()

print(rna)

if rna == "m" or rna == "t" or rna == "r":

   print("valid")

else:

   print("invalid")

Answer 3:

dnaSquence = input("Enter the DNA sequence: ")

type = "valid"

for char in dnaSquence:

   if char not in ["A", "C", "G", "T"]:

       type = "invalid"

       break

print(type)

Answer 4:

rnaSquence = input("Enter the RNA sequence: ")

type = "valid"

for char in rnaSquence:

   if char not in ["A", "C", "G", "U"]:

       type = "invalid"

       break

print("valid")

Explanation:

There are three types of DNA; Type A, Type B and Type Z.

A DNA sequence consists of; A, C, G and T.

There are three types of RNA; mRNA, tRNA and rRNA.

An RNA sequence consists of; A, C, G and U.

Code Explanations:

Code 1:

dna = input("Enter DNA type: ")

dna = dna.upper()

print(dna)

if dna == "A" or dna == "B" or dna == "Z":

   print("valid")

else:

<em>    print("invalid")</em>

  1. prompts and Takes a single character input
  2. converts the character to upper case
  3. compares the input to the DNA types
  4. Prints "valid" for a valid input else prints "invalid"

Code 2:

rna = input("Enter DNA type: ")

rna = rna.lower()

print(rna)

if rna == "m" or rna == "t" or rna == "r":

   print("valid")

else:

<em>    print("invalid")</em>

<em />

  1. prompts and Takes a single character input
  2. converts the character to lower case
  3. compares the input to the RNA types
  4. Prints "valid" for a valid input else prints "invalid"

Code 3:

Answer 3:

dnaSquence = input("Enter the DNA sequence: ")

type = "valid"

for char in dnaSquence:

   if char not in ["A", "C", "G", "T"]:

       type = "invalid"

       break

print(type)

  1. It prompts for a DNA sequence.
  2. Declares a string variable "type" and initializes type to valid.
  3. The FOR loop checks every character in the DNA sequence.
  4. If the character is not in the list [A, C, G, T] type becomes invalid and the loop breaks and the type "invalid" is printed to the screen.
  5. if all the characters are in the list, then type will remain valid and will be printed to the screen.

Code 4:

rnaSquence = input("Enter the RNA sequence: ")

type = "valid"

for char in rnaSquence:

   if char not in ["A", "C", "G", "U"]:

       type = "invalid"

       break

print("valid")

  1. It prompts for a RNA sequence.
  2. Declares a string variable "type" and initializes type to valid.
  3. The FOR loop checks every character in the RNA sequence.
  4. If the character is not in the list [A, C, G, U] type becomes invalid and the loop breaks and the type "invalid" is printed to the screen.
  5. if all the characters are in the list, then type will remain valid and will be printed to the screen.

7 0
3 years ago
What does cramming to hand in an assignment
Vikki [24]
Honestly gotta say cramming in an assignment doesnt help at all

5 0
3 years ago
The parts of a memo are _____.
RoseWind [281]

They would be:

Reader’s name, your name, the date, the subject, and the body of the memo.

4 0
3 years ago
Read 2 more answers
The format painter button is found in the ____ group on the home tab of the ribbon.
Amanda [17]
<span>The format painter button is found in the <u><em>clipboard</em></u><em> </em>group on the home tab of the ribbon</span>
6 0
3 years ago
Consider the practice of outsourcing programmers, a common practice in many U.S. businesses. Think about how this practice is us
GuDViN [60]

The practice of outsourcing programmers is known to be the act of  sharing or delegating as well as handing over control of programming and its associated tasks to any form of  external service provider that is said to be very good in that field and has the power and capabilities to handle the technical and operational areas of a programming project.

<h3>What is outsourcing and why is it always practiced?</h3>

Outsourcing is known to  be a kind of a business practice that entails the act of hiring a party that is known to be outside a company to carry out services or make goods that are said to be traditionally carried out in-house.

Note that The practice of outsourcing programmers is known to be the act of  sharing or delegating as well as handing over control of programming and its associated tasks to any form of  external service provider that is said to be very good in that field and has the power and capabilities to handle the technical and operational areas of a programming project.

Learn more about outsourcing  from

brainly.com/question/12101789

#SPJ1

5 0
2 years ago
Other questions:
  • The disk drive is a secondary storage device that stores data by _____ encoding it onto a spinning circular disk.
    14·1 answer
  • True or false. Every word has only one correct spelling and pronunciation.
    6·1 answer
  • Write a paragraph expressing how you'd use the computer to enhance your place of work.​
    10·1 answer
  • Fill in the code to complete the following function for computing a Fibonacci number. public static int fib(int index) { if (ind
    6·1 answer
  • The duties of a database administrator include determining which people have access to what kinds of data in the database; these
    13·2 answers
  • Create a list of strings based on a list of numbers The rules:_______
    8·1 answer
  • The conversion of decimal 0.0625 into its binary equivalent. Explain.
    7·1 answer
  • Data management technology consists of the: Group of answer choices physical hardware and media used by an organization for stor
    13·1 answer
  • Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin
    6·1 answer
  • You designed a program to find the midpoint of two points. Which step below corresponds to finding the average of the x-coordina
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!