Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- //b. Write the definition of the method doubleArray that initializes the elements of beta to two times the corresponding elements of alpha.
- public class Testing_arrays {
- static Scanner console = new Scanner(System.in
- );
- public static void main(String[] args) {
- int [] beta = new int[20];
- int [] gamma = {11, 13, 15, 17};
- int [] alpha = new int[20];
- int i, j;
- System.out.println("Enter twenty values.");
- inputArray(alpha);
- doubleArray(beta);
- System.out.println("The value of array [2] is " + alpha[2]);
- System.out.println("The value of array beta [2] is "+ beta[2]);
- public int inputArray(int[] infoArray)
- {
- for (i = 0; i < infoArray.length; i++)
- {
- infoArray[i] = console.nextInt();
- }
- }
- public int doubleArray(int[] infoDouble)
- {
- for (i = 0; i < alpha.length; i++)
- infoDouble[i] = alpha[i]*2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement