Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program that creates an array of ten integers. It should put ten ra

ID: 3582880 • Letter: W

Question

Write a Java program that creates an array of ten integers. It should put ten random numbers from 1 to 100 in the array. It should copy all the elements of that array into another array of the same size and change the last value in the first array to -7. Then display the contents of both arrays. Create an array of ten integers Fill the array with ten random numbers (1-100) Copy the array into another array of the same capacity Change the last value in the first array to a -7 Display the contents of both arrays

Explanation / Answer

import java.util.*
import java.lang.*
public static void main(String[] args){
Random ran = new Random();
   int array1[10];
   int array2[10];
   for(int i=0;i<10;i++){
int ans = ran.nextInt(100)+1;
   array1[i] = ans;
   array2[i] = ans;
   }
   array1[9] = -7;
   for(int i=0;i<10;i++){
System.out.println(array1[i] + " ");
   }
System.out.println(" ");
for(int i=0;i<10;i++){
System.out.println(array1[i] + " ");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote