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

Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. Wri

te the definition of the function double Array that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. Write the definition of the function copy AlphaBeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. Make sure that you prevent the function from modifying the elements of alpha and beta. Write the definition of the function printArray that prints any one-dimensional array of type int. Print 15 elements per line.
Computers and Technology
1 answer:
Alina [70]2 years ago
4 0

Answer:

In Java:

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

   int[] alpha = new int[20];

   for(int i = 0;i<20;i++){

       alpha[i] = input.nextInt();

   }

   return alpha;}

public static  int[] doubleArray(int [] alpha){

   int[] beta = new int[20];

   for(int i = 0;i<20;i++){

       beta[i] = 2 * alpha[i];

   }

   return beta;

}

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

   int [] AlphaBeta = new  int[10];

   for(int i = 0;i<5;i++){

       AlphaBeta[i] = alpha[i];

   }

   int count = 5;

   for(int i = 15;i<20;i++){

       AlphaBeta[count] = beta[i];

       count++;

   }

   return AlphaBeta;

}

public static void printArray(int [] alpha){

   for(int i = 0;i<20;i++){

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

       if((i+1)%15 == 0){

           System.out.println(" ");

       }

   }

}

Explanation:

The inputArray is defined here

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

This declares alpha array of 20 elements

   int[] alpha = new int[20];

The following iteration gets input from the user into the array

<em>    for(int i = 0;i<20;i++){</em>

<em>        alpha[i] = input.nextInt();</em>

<em>    }</em>

This returns the alpha array

   return alpha;}

The doubleArray is defined here. It takes the alpha array as its input parameter

public static  int[] doubleArray(int [] alpha){

This declares beta of 20 integers

   int[] beta = new int[20];

This populates beta by 2 * alpha[i]

<em>    for(int i = 0;i<20;i++){</em>

<em>        beta[i] = 2 * alpha[i];</em>

<em>    }</em>

This returns the alpha array

   return beta;}

The copyAlphaBeta array is defines here

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

This declares AlphaBeta as 10 elements

   int [] AlphaBeta = new  int[10];

This populates the first 5 elements of AlphaBeta with the first 5 of alpha

<em>    for(int i = 0;i<5;i++){</em>

<em>        AlphaBeta[i] = alpha[i];</em>

<em>    }</em>

   int count = 5;

This populates the last 5 elements of AlphaBeta with the last 5 of beta

<em>    for(int i = 15;i<20;i++){</em>

<em>        AlphaBeta[count] = beta[i];</em>

<em>        count++;</em>

<em>    }</em>

This returns the AlphaBeta array

   return AlphaBeta;

}

The printArray is defined here. It takes the alpha array as its input parameter

public static void printArray(int [] alpha){

This iterates through alpha array

   for(int i = 0;i<20;i++){

This prints each element of the array

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

A new line is started after the 15th element

<em>        if((i+1)%15 == 0){</em>

<em>            System.out.println(" ");</em>

<em>        }</em>

   }

}

See attachment for complete program which includes the main

Download txt
You might be interested in
John typed 545 words in 35 minutes, what is his typing speed
Katarina [22]

Answer: 545 words per 35 mins

Explanation:

4 0
2 years ago
Read 2 more answers
Analyze the following code.
vazorg [7]

Answer:

The correct answer for the given question is "The program has a runtime NullPointerException because test is null while executing test.x"

Explanation:

In this code their is run time exception will occur in Main method i.e "java.lang.NullPointerException "because the object of the Test class i.e test will initialized by "null" .So on executing the statement test.x  it gives an Runtime Exception.The "NullPointerException" can occur if we assign the object to the "null" value that why it produce an java.lang.NullPointerException

8 0
3 years ago
Which three features can be configured in the BIOS settings to secure a computer?
Vladimir79 [104]
Passwords, TPM, and Drive Encryption.

Hope this helps. :)
8 0
2 years ago
Which is a major drawback of muliuser procesing of a database
-BARSIC- [3]

The main drawback of multiuser processing of a database is:

  • Lost-update problem.

<h3>What is  lost-update problem?</h3>

In the area of lost update problem, an update that has been carried on to a data item by a transaction is said to be lost as it is known to be overwritten by the update that has been carried on by another transaction.

Therefore, The main drawback of multiuser processing of a database is:

  • Lost-update problem.

Learn more about database from

brainly.com/question/26096799

#SPJ12

3 0
1 year ago
Which is the output of the formula =XOR(120&lt;102;83=83;51&lt;24)??
Greeley [361]
The output of the formula will be TRUE because '83 = 83' is the only true expression of that three expressions present in the formula.
The output of the XOR function will be TRUE in case only one logical expression is true and FALSE otherwise.
7 0
3 years ago
Read 2 more answers
Other questions:
  • program students can get credit for their high school classes as long as they take a specific courses that a college will accept
    13·2 answers
  • For the description below, develop an E-R diagram:
    9·1 answer
  • Why are you unable to modify the budget file, when you have the allow full control ntfs permission?
    5·1 answer
  • 1. In your own words, describe the purpose of a for a loop.
    11·1 answer
  • Which technology concept uses computer resources from multiple locations to solve a common problem?
    11·2 answers
  • I need help also this counts as my second giveaway and last for today
    12·2 answers
  • What is data analysing data and give three examples ?​
    9·1 answer
  • Aniyah is setting up a group of computers in her office that will share several devices. Which type of operating system should s
    6·1 answer
  • What is an example of work performed by an integration platform as a service (ipaas)?
    14·2 answers
  • write a function named get majority last name that accepts as its parameter a dictionary from strings to strings the keys of the
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!