Part-2: Write a program that includes in its MainClass the following methods: 1. A method called printArray that takes an array of double values and prints its elements in their original order on the same line with one space between each two elements. The method should print a new line after printing the array elements. 2. A method called greaterThan that takes a double value and an array of doubles as parameters and returns the number of array elements that are greater than or equal the passed double value. 3. A method called reverseArray that takes an array of doubles and reverses the order of the array elements. Note that this method must not create a new array, it must reverse the array in its place. For example, if the passed array is 6.1, 2.5, 5.3, 1.7, 8.3, after invoking the method the array must become: 8.3, 1.7, 5.3, 2.5, 6.1 4. A method called addNumbers that takes an array of doubles, and a variable length argument list of doubles. The method must return a new array that results from adding the numbers passed to the variable length argument list to the end of the array in the first parameter. For example, if the array 6.1, 2.5, 5.3, 1.7, 8.3 is passed to the first parameter, and the numbers 1.2 2.3 3.4 are passed to the variable length argument list, the method must return the array 6.1, 2.5, 5.3, 1.7, 8.3, 1.2, 2.3, 3.4. 5. In your main method: - Declare, create, and initialize the following array of doubles with the following name: list: 3.2 4.2 1.2 2.9 6.3 8.5 5.2 1.1 Print elements of the array list by invoking the printArray method. - Print the count of numbers that are greater than of 5.0 in the array list by invoking the method greaterThan. The printed statement must be: "Count of numbers greater than 5.0 in list is: ...". Reverse the array list by invoking the method reverseArray. Print the array after being reversed. - Add the numbers 2.1, 1.3, 0.4 to the array list by invoking the addNumbers method and print the array after adding the element.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Part-2: Write a program that includes in its MainClass the following methods:
1. A method called printArray that takes an array of double values and prints its elements
in their original order on the same line with one space between each two elements. The
method should print a new line after printing the array elements.
2. A method called greaterThan that takes a double value and an array of doubles as
parameters and returns the number of array elements that are greater than or equal the
passed double value.
3. A method called reverseArray that takes an array of doubles and reverses the order of
the array elements. Note that this method must not create a new array, it must reverse
the array in its place.
For example, if the passed array is 6.1, 2.5, 5.3, 1.7, 8.3, after invoking the method the
array must become:
8.3, 1.7, 5.3, 2.5, 6.1
4. A method called addNumbers that takes an array of doubles, and a variable length
argument list of doubles. The method must return a new array that results from adding
the numbers passed to the variable length argument list to the end of the array in the
first parameter.
For example, if the array 6.1, 2.5, 5.3, 1.7, 8.3 is passed to the first parameter, and the
numbers 1.2 2.3 3.4 are passed to the variable length argument list, the method must
return the array 6.1, 2.5, 5.3, 1.7, 8.3, 1.2, 2.3, 3.4.
5. In your main method:
Declare, create, and initialize the following array of doubles with the following name:
list:
-
3.2
4.2
1.2
2.9
6.3
8.5
5.2
1.1
- Print elements of the array list by invoking the printArray method.
- Print the count of numbers that are greater than of 5.0 in the array list by invoking the
method greaterThan. The printed statement must be: “Count of numbers greater than
5.0 in list is: ...".
- Reverse the array list by invoking the method reverseArray. Print the array after being
reversed.
- Add the numbers 2.1, 1.3, 0.4 to the array list by invoking the addNumbers method
and print the array after adding the element.
Transcribed Image Text:Part-2: Write a program that includes in its MainClass the following methods: 1. A method called printArray that takes an array of double values and prints its elements in their original order on the same line with one space between each two elements. The method should print a new line after printing the array elements. 2. A method called greaterThan that takes a double value and an array of doubles as parameters and returns the number of array elements that are greater than or equal the passed double value. 3. A method called reverseArray that takes an array of doubles and reverses the order of the array elements. Note that this method must not create a new array, it must reverse the array in its place. For example, if the passed array is 6.1, 2.5, 5.3, 1.7, 8.3, after invoking the method the array must become: 8.3, 1.7, 5.3, 2.5, 6.1 4. A method called addNumbers that takes an array of doubles, and a variable length argument list of doubles. The method must return a new array that results from adding the numbers passed to the variable length argument list to the end of the array in the first parameter. For example, if the array 6.1, 2.5, 5.3, 1.7, 8.3 is passed to the first parameter, and the numbers 1.2 2.3 3.4 are passed to the variable length argument list, the method must return the array 6.1, 2.5, 5.3, 1.7, 8.3, 1.2, 2.3, 3.4. 5. In your main method: Declare, create, and initialize the following array of doubles with the following name: list: - 3.2 4.2 1.2 2.9 6.3 8.5 5.2 1.1 - Print elements of the array list by invoking the printArray method. - Print the count of numbers that are greater than of 5.0 in the array list by invoking the method greaterThan. The printed statement must be: “Count of numbers greater than 5.0 in list is: ...". - Reverse the array list by invoking the method reverseArray. Print the array after being reversed. - Add the numbers 2.1, 1.3, 0.4 to the array list by invoking the addNumbers method and print the array after adding the element.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY