Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an array called salaries to store 10 double values Create and initialize

ID: 639384 • Letter: C

Question

Create an array called salaries to store 10 double values

Create and initialize a one dimensional array called evens to be the first 5 even numbers.


Create a 2 dimensional array called table to have 4 columns and 6 rows.

Create and initialize an array called identity to hold the values of 3x3 identity matrix


Create an array called values to hold 4 integer values

Now create a for loop to interactively get all 4 values and calculate the sum of the values


Display the average to the console and then do the same to display to the message dialog boxes.

Using the values in number 4 use a nested for loop to print the values like a true matrix values should be printed.

What method is used to return the number of elements in an array and how about an ArrayList.


Use an enhanced for loop to print the numbers in this array each separated by 2 spaces

Create an ArrayList called students to hold Strings.

Add 4 names to the list

Remove the first name

Now put in the second location the name John


Replace the first name with your first name

HELP!!

Explanation / Answer

import java.util.ArrayList;
import java.util.Scanner;


public class Arrays {
   public static void main(String args[]){
       Scanner in = new Scanner(System.in);
       int evens[] = {2, 4, 6, 8, 10};
       int table[][] = new int[6][4];
       int identity[][] = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}};
       int values[] = new int[4];
       int sum = 0;
       for(int i = 0; i < values.length; ++i){
           System.out.print("Value " + (i + 1) + ": ");
           values[i] = in.nextInt();
           sum += values[i];
       }
       System.out.printf("Average of the values is %.2f ", (sum / 4.0));
       for(int i = 0; i < 4; ++i){
           for(int j = 0; j < 4; ++j){
               System.out.print(j + " ");
           }
           System.out.println();
       }
       int[] numbers = {3, 5, 7, 11};
       System.out.println("Size of numbers array is " + numbers.length);
       ArrayList<String> students = new ArrayList<String>(4);
       students.add(0, "Cristiano Ronaldo");
       students.add(1, "Lionel Messi");
       students.add(2, "Garath Bale");
       students.add(3, "Neymar Jr.");
       System.out.println(students);
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote