Question: Assignment Requirements Create a new Java Project in your Eclipse workspace named as before, smith 5 or jones 5 for example. Create a package with

Assignment Requirements
Create a new Java Project in your Eclipse workspace named as before, smith5 or jones5 for example.
Create a package with the very same name as your project name.
In this one package, write one Java program for each exercise as required below.
Adhere to naming conventions for variables and classes as in section 2.8.
Choose descriptive variable names and identifiers in all programs.
Start each program with your name and SPC ID# in a comment.
Add a few more comments in each program to explain what your code is doing.
When all programs are done, locate your project folder in your workspace.
Right-click on the project folder folder (don't open it!) and select "Send to"--> "Compressed (zipped) folder". This will make a zip with the same name as your project.
Upload the zip to this drop box. Type your collaboration statement into the message area.
Submit your assignment.
1. Declare an array to hold eight integers. Use a for loop to add eight random integers, all in the range from 50 to 100, inclusive, to this array. Duplicates are okay. Next, pass the array to a method that sorts the array and returns another array containing only the largest and smallest elements in the original array. Print these two values in main. Then use a foreach loop to display all elements of the sorted array on one line separated by a single space. This latter loop should also count the odd and even numbers in the array and determine the sum of all elements in the array.
SAMPLE OUTPUT
The lowest element is 59
The highest element is 96
Here is the array
5964767780889196
Evens: 5, odds: 3
Total: 631
2. Write a method named sumInts that can take a variable number of int arguments (see page 274-255 command-line arguments) and return the sum of these arguments. The ints to be summed up must be entered as command line arguments. Command line arguments can be simulated in Eclipse. Watch the video. In the main method, display the ints that were entered on the command line. Then execute sumInts and display the sum it returns.
TWO SAMPLE OUTPUTS
Passing [1,2,3,4,5]
Sum is 15
Passing [10,20,30]
Sum is 60
3. Create an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time. See Sample Output.
SAMPLE OUTPUT
Here is the list
Lionel Messi
Drake
Adele
Dwayne Johnson
Beyonce
Here is the new list
* Lionel Messi * Drake * Taylor Swift * Adele * Beyonce
Using an iterator, here is the list
Lionel Messi
Drake
Taylor Swift
Adele
Beyonce

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!