Question

Purpose: The JAVA application will allow the student to; I. demonstrate the declaration of an array;...

Purpose: The JAVA application will allow the student to;

I.

demonstrate the declaration of an array;

II.

demonstrate the initialization of the array;

III

demonstrate the printing of the elements of the array.

Create a new file called "Array5A”

.

1.

Prepare a document box (tell me that task(s) the application is

to accomplish, how it will accomplish the tasks, the author of

the application, the date of completion, and any additional

notes.)

2.

Write a Java statement to create your header.

3.

Write a Java statement to create your "main" header.

4.

Create an array of type "double" to contain 4 elements. Then

name your array "salary".

5.

Write a series of Java statements of to initialize the 4 elements

of the "salary" array with the following

values:

5.25 6.55 10.25 16.85

(Note: initialize each element of the array individually, NO

LOOPS should be used or points will be deducted.)

6.

Output should be:

"Salaries one by one are: "

Write a series of print statements to print out the values

contained in the 4 "salary" array elements.

(Note: print each element of the array individually, no

loops)

Use your resources, examples from the PPT!

Required Elements:

  1. IPO chart (Defining Diagram)
  2. Solution Algorithm
  3. Code
  4. Run and Debug the code
  5. Document (comments)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part I:

====

public class Array5A {
    public static void main(String[] args){
        int integerAyyay[];
        //int [] array;  -> this is also valid declaration

        //Initialization of array
        integerAyyay = new int[]{1,2,3,4,5};
        System.out.println("First element in array: "+integerAyyay[0]);
        System.out.println("Second element in array: "+integerAyyay[1]);
        System.out.println("Third element in array: "+integerAyyay[2]);


    }
}

Part 2:

=====

/**
 *This is document box, where you can write details about your program
 * like author, task, date and purpose
 *
 * This is first question answer in part 2
 */

//Write a Java statement to create your header. 2nd question
//JAva never had a concept of header. Please comment about this so that I can edit the answer
public class ArrayDemo {
    public static void main(String[] args){ //Main header. Third question answer
            double[] salary = new double[4]; // 4th question
            //Fifth
            salary[0]=5.25;
            salary[1]=6.55;
            salary[2]=10.25;
            salary[3]=16.85;

            System.out.println("Salaries one by one are: "); //6th question
            System.out.println(salary[0]);
            System.out.println(salary[1]);
            System.out.println(salary[2]);
            System.out.println(salary[3]);

    }

}

Please comment about second question and also comment if you need any help.

Add a comment
Know the answer?
Add Answer to:
Purpose: The JAVA application will allow the student to; I. demonstrate the declaration of an array;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate...

    JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate passing array reference to a method;        III. Demonstrate creating array of objects that prints out only x 0.0 for all objects. PROJECT 5C - ARRAYS Create a new file called " EventArray5C". There are some "challenging" directions in this project. . 1.Prepare a document box (tell me that task(s) the application is to accomplish, how it will accomplish the tasks, the author of...

  • Write program in JAVA with a method that returns an array. The method should accept as input a co...

    Write program in JAVA with a method that returns an array. The method should accept as input a comma-delimited string with three values from a user. The array should store each value in a different element. Use Try..Catch error handling and print any failure messages, or print success from within method if execution is successful (see Chapter 13 in the text). Call the method from the main method of the program to demonstrate its functionality by looping through the array...

  • In Java write the following array- processing methods into the same application, Lab13.java. Use the main...

    In Java write the following array- processing methods into the same application, Lab13.java. Use the main method in this application to test your methods. 1) Write the void method, shiftLeft, which accepts an array of int and changes the elements of this array so that the index of each element is now less by one and the last element of the array is now zero. For example, if the parameter array is {7, 3, 2, 9, 5}, then when this...

  • Write code that declares an array of integer values that will represent the first five even...

    Write code that declares an array of integer values that will represent the first five even numbers: 2, 4, 6, 8, 10. Add code to initialize each element of the array with the even number values shown above. Add code to calculate the product of the array elements, and store the result in a variable named product. You must access the array elements to accomplish this. Do not write product = 2 * 4 * 6 * 8 * 10;...

  • Write a JAVA program with methods that initializes an array with 20 random integers between 1...

    Write a JAVA program with methods that initializes an array with 20 random integers between 1 and 50 and then prints four lines of output, containing 1)The initialized array. 2)Every element at an even index. 3)Every even element. 4)All elements in reverse order. Requirements (and hints): 1. Build a method that takes any integer array as input and prints the elements of the array. ALL printing in this lab must be done using a call to the printArray method and...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods...

    *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...

  • Declare a 4 x 5 array called N. Write a subprogram called printlt to print the...

    Declare a 4 x 5 array called N. Write a subprogram called printlt to print the values in N. Use this subprogram to print the values in the array after each part of the initialization exercise. Write the loops to initialize the array to the following: A. 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 B. 1 1 1 1 1 2 2 2 2 2 3 3...

  • JAVA Objectives: 1. Apply linear search algorithm 2. Apply select sort algorithm 3. Apply array iteration...

    JAVA Objectives: 1. Apply linear search algorithm 2. Apply select sort algorithm 3. Apply array iteration skill Problem description: Write the following eight methods and write a main function to test these methods // return the index of the first occurrence of key in arr // if key is not found in arra, return -1 public static int linearSearch(int arr[], int key) // sort the arr from least to largest by using select sort algorithm public stati void selectSort(int arr[])...

  • Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...

    Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT