Use a for loop to generate an array of ten random integers, all in the range from 100 to 200, inclusive. Use the Arrays class to both sort and display the entire array. Next, pass the array as the sole argument to a method that doubles each element of the array and then returns the array. Use a foreach loop to show all elements in the returned array on one line separated by a single space. This latter loop should also determine the sum of all elements in the returned array.
1
Expert's answer
2016-09-14T12:49:04-0400
import java.util.Arrays; import java.util.Random;
public class Main { public static void main(String[] args) { int[] arr = new int[10]; Random r = new Random();
for (int i = 0; i < 10; i++) { arr[i] = r.nextInt((200 - 100) + 1) + 100; }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments