Create a new Java Project in your Eclipse workspace named as before, smith3 or jones3 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. Choose descriptive variable names and identifiers in all programs 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 59 64 76 77 80 88 91 96 Evens: 5, odds: 3 Total: 631
Hello! I need help with the first problem, here are the requirements!
Please use Eclipse if possible! and show a screenshot of the output would also be helpful. Also comments displaying what the code is doing is also very helpful so I understand it. Thank you so much!!! I had asked this question before but sadly it was not done correctly :(
Assignment Requirements
- Create a new Java Project in your Eclipse workspace named as before, smith3 or jones3 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.
- Choose descriptive variable names and identifiers in all programs
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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images