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, smith or jones 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
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.
Rightclick on the project folder folder dont 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.
Declare an array to hold eight integers. Use a for loop to add eight random integers, all in the range from to 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
The highest element is
Here is the array
Evens: odds:
Total:
Write a method named sumInts that can take a variable number of int arguments see page commandline 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
Sum is
Passing
Sum is
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 and remove the name at index 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
