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
Alchen [17]
3 years ago
5

9.6 Code Practice: Question 2

Computers and Technology
1 answer:
posledela3 years ago
5 0

A method named "sumArray" to your last program that takes an array as a parameter and returns the sum of its values.

Explanation:

The program is used to add a list of arrays.

import java.util.Scanner;

public class MethodsArrays {

   public static int[] fillArray() {

       Scanner scan = new Scanner(System.in);

       int size = scan.nextInt();

       int array[] = new int[size];

       int pos=0;

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

           pos=i+1;

           System.out.println("Enter element " + pos);

           array[i]=scan.nextInt();

       }

       return array;

   }

   public static int sumArray(int [] array) {

       int sum=0;

       for(int i=0; i<array.length-1; i++) {

           sum=array[i]+array[i+1];

       }

       return sum;

   }

   }

   public static void printArray(int [] array) {

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

           System.out.print(array[i] + " ");

       }

   }

   public static void main(String[] args) {

       fillArray();

       System.out.println("Sum=" + sumArray(array));

       printArray(array);

   }

}

You might be interested in
Face book requires you to change your password regularly<br> a. TRUE<br> b. FALSE
Irina-Kira [14]
The answer is for this question is false
8 0
3 years ago
Jhon bought a new printer for his desktop computer. It does not work even though he checked all the cables and cords. What do yo
ExtremeBDS [4]
Im not for sure but it might be B or C
4 0
3 years ago
Read 2 more answers
Why is stranded rather than solid cable used for patch cables? Why is it critical not to score the jacket too deeply when stripp
Serggg [28]

Answer:

The definition of the issues is listed throughout the section down.

Explanation:

  1. Stranded cables are somewhat more compact and can be mounted quickly. Strong cables become rigid in design, and they are not versatile for installation. In comparison with solid connectors, amplification is indeed high.
  2. Unless the innermost layer including its wire is broken as we attempt to connect the cable, it will not function. So, whenever stripping the cables through the walls, it's indeed important not to rank the jack too profoundly.
  3. It would be quick to untwist the cable and then will ensure that perhaps the connection is appropriate for the most widely encountered rj-45 connection whenever the wiring of 0.5 inches becomes coupled up.
  4. If we don't keep the right pin colors in order, the relation won't work. Afterward, when another connexon is broken due to many complications, it would be impossible to figure out the contacts unless the pins coloring are not always in sequence.
  5. The connection pairs can be cut off through 0.5 inches within about therefore the gap within the connector is narrower and the wire would not be correctly attached if we break the cable further. The link is lost and the cable does not run properly.
  6. It is necessary to ensure that perhaps the wires are forced to the end of the platform since the connexon will indeed be broken as well as the connector would not operate unless the wires aren't moved. The wires will fall out of another socket as well.
  7. Before even being incorporated into another crimping unit, it is good to carefully check the connection sequence to ensure that perhaps the wires are to the end since it is impossible to verify the sequence until the wires are attached to something like the connector. Unless the connections are not always in alignment, the link will also not be provided and indeed the wire would not operate correctly, even if the link is provided. Such wires can also be presented to use load barriers, and that it's the simplest operation.
  8. The Durability Tester has been used to determine the hardness between two stages, whereas the connection efficiency is tested using the qualification tester.

8 0
3 years ago
Help me learn how to code
Sholpan [36]
What type of coding are you trying to learn?
3 0
3 years ago
Read 2 more answers
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hou
Nuetrik [128]

Answer:

Following is the program in the python language

hr = input("input hours:") #Read input by user

h1 = float(hr)

rate =input("Input Rate:") #Read RATE BY USER

r1 = float(rate) #CONVERT INTO FLOAT

if h1 <= 40: #check condition

   t=h1 * r1

   print (t) #DISPLAY

else :#else block

   t1=(40 * r1) + (h1 -40) * r1 * 1.5

   print('The pay is :')

   print(t1)#DISPLAY

Output:

input hours:45

Input Rate:10.50

The pay is :

498.75

Explanation:

Following are the description of program

  • Read the value of hour in the "hr" variable and convert into the float value in the "h1" variable .
  • Read the value of rate in the " rate" variable and convert into the float value in the "r1" variable .
  • After that check the condition of hour if block if the hour is less then or equal to 40 then it multiplied h1 *t1 otherwise else block will be executed and print the value of pay .

5 0
4 years ago
Other questions:
  • Using commands you learned in lessons 1 and 2. Get your IP address, netmask, DNS hostname, and MAC address. Compare these with y
    5·1 answer
  • Pressing the Ctrl+Home keys moves the insertion point to the
    5·1 answer
  • Choosing the “Quick Print” button will ____________.
    14·1 answer
  • Is the very calculation that we wish to avoid. Obtain a second equation by multiplying both sides of this equation by 1.06, then
    5·1 answer
  • Fill in the blanks in the SQL statement below that will list the invoice number, invoice total and credit which is the total sum
    14·1 answer
  • Why is it important to think about the programming language to use?
    8·1 answer
  • Open excel program then use the (IF) function to fill the column of (Expensive/Cheap) then save your
    9·1 answer
  • Match the order in which you should develop a plan:
    7·1 answer
  • List four types of Web browsers<br>​
    5·2 answers
  • Draw and implement of an organization which have 125 employees. use the following features 1.email services 2.lan communication
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!