![jetblackcap](/avatars/10931.jpg)
jetblackcap
19.02.2021 •
Computers and Technology
Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. Write 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.
Solved
Show answers
More tips
- C Computers and Internet How Do You Refill Cartridges?...
- F Family and Home How to Keep Your Home Warm: Tips and Tricks...
- D Dating, Love, Relationships Does a Person s Character Depend on the Color of Their Eyes?...
- O Other Childhood Fears: What Many of Us Experienced...
- H Health and Medicine Simple and Effective: How to Get Rid of Cracked Heels...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
Answers on questions: Computers and Technology
- C Computers and Technology Will anyone follow me on wattpad my acc is IzukuMidoriaxxX...
- C Computers and Technology Are mobile devices that are used to give drivers advance warning of work zones or other unusual conditions....
- S Social Studies 5. What was the name of the secret society that was trying to re-unite all Serbs under one rule? a. The Red Baron b. Big Bertha c. The Black Hand d. The Dogfighters...
- M Mathematics I need help with this urgent...
- M Mathematics If SV is congruent UV, SR = 4x-1, and RU = x+8, what is the value of SU?...
- M Mathematics What is the place value of 7 in the number 1667989.023...
- C Chemistry Calculate the number of oxygen atoms present in a 58.6 mL sample of gaseous nitrogen dioxide at standard temperature and pressure....
- B Biology Que controla el hemisferio derecho...
- M Mathematics can someone plz do free points I lost all my points I had 600 but a mod took them away now I have 9 and they deleted most of my questions i tried to answer 2 questions...
- C Chemistry Percent of Light Intensity on Moon Visible through Lunar Cycle Intensity 100 76 50 25 Lunar Cycle O waxing gibbous waning crescent O waning gibbous O waxing crescent...
Ответ:
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
for(int i = 0;i<20;i++){
alpha[i] = input.nextInt();
}
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]
for(int i = 0;i<20;i++){
beta[i] = 2 * alpha[i];
}
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
for(int i = 0;i<5;i++){
AlphaBeta[i] = alpha[i];
}
int count = 5;
This populates the last 5 elements of AlphaBeta with the last 5 of beta
for(int i = 15;i<20;i++){
AlphaBeta[count] = beta[i];
count++;
}
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
if((i+1)%15 == 0){
System.out.println(" ");
}
}
}
See attachment for complete program which includes the main
Ответ:
On April 27, 1861, Lincoln suspended the writ of habeas corpus between Washington, D.C., and Philadelphia to give military authorities the necessary power to silence dissenters and rebels. Under this order, commanders could arrest and detain individuals who were deemed threatening to military operations.