1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yulyashka [42]
2 years ago
8

Class Main {

Computers and Technology
1 answer:
tatyana61 [14]2 years ago
6 0

See below for the modified program in Java

<h3>How to modify the program?</h3>

The for loop statements in the program are:

  • for (int i = 0; i < arr.length; i++) { arr[i] = rd.nextInt(1000); }
  • for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]); }

To use the enhanced for loop, we make use of the for each statement.

This syntax of the enhanced for loop is:

for(int elem : elems)

Where elem is an integer variable and elems is an array or arrayList

So, we have the following modifications:

  • i = 0; for (int num : arr){ arr[i] = rd.nextInt(1000); i++;}
  • for (int num : arr) { System.out.println(num); }

Hence, the modified program in Java is:

class Main {

static int[] createRandomArray(int nrElements) {

Random rd = new Random();

int[] arr = new int[nrElements];

int i = 0;

for (int num : arr){

arr[i] = rd.nextInt(1000);

i++;

}

return arr;

}

static void printArray(int[] arr) {

for (int num : arr) {

System.out.println(num);

}

}

}

public static void main(String[] args) {

int[] arr = createRandomArray(5);

printArray(arr);

}

}

Read more about enhanced for loop at:

brainly.com/question/14555679

#SPJ1

You might be interested in
PLEASE ANSWER FAST.one of the barriers for early "talkies" was the need to manually crank the projector and manually synchronize
OleMash [197]

Answer:?

Explanation:?

7 0
3 years ago
What is the recommended secure protocol for voice and video applications? secure real-time transport protocol (srtp) hypertext t
snow_tiger [21]
The recommended secure protocol for voice and video applications is the Secure<span> Real-time Transport </span>Protocol<span> (SRTP) protocol. SRTP is a Real-time Transport </span>Protocol (RTP) profile used to  to provide encryption, message authentication and integrity.
The default cipher of SRTP is the Advanced Encryption Standard<span> (AES) .</span>
8 0
4 years ago
When comparing different biometric systems, one of the most important metrics used is called the _________, which represents the
Airida [17]

Answer:

Crossover Error Rate(CER)

Explanation:

Crossover Error Rate is an important metrics in the biometric systems.It is the value of FRR and FAR when the sensitivity is framed so that FRR and FAR are equal. The Crossover Error Rate(CER) is suitable for quantitative comparison of different biometric devices, applications or solutions.

8 0
3 years ago
Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
ExtremeBDS [4]
<span>C) magnetic resonance imaging (MRI) 

hope it helped

</span>
5 0
3 years ago
What are the advantages and disadvantages of nuclear energy?
Vilka [71]
Advantages: Nuclear energy has the ability to produce electricity without greenhouse gas emissions. It produces electricity without pollution

Disadvantages: The nuclear weapons threats. Some reactors produce plutonium which can be used to make nuclear weapons
7 0
3 years ago
Other questions:
  • Will upvote all answers
    7·1 answer
  • When you declare a string data type, you are actually creating an object from the?
    5·1 answer
  • Information flows:
    11·1 answer
  • which statement draws an accurate comparison between social media marketing and conventional marketing?
    13·1 answer
  • A user is attempting to format a 4 TB HDD using NTFS but only has the option to format the disk with a size of approximately 2 T
    15·1 answer
  • What type of ransomware was developed to block the user from accessing the computer and encrypts all the files on the user's dev
    5·2 answers
  • 1) Using the density equation d=m/V: What is the density of a piece of metal with a mass o
    10·1 answer
  • Explain the main components of a computer system​
    12·1 answer
  • Which of the following statements best explains how multitasking works in the human mind?
    11·1 answer
  • What are the local, state, and national opportunities that may be available to those who participate in CTSOs?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!