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
What is the safety for working ina facility that performs xrays?
mylen [45]

Hey and thanks for giving me the chance to serve u

For the nuclear industry, the NRC, amongst other things, dictates exposure limits to both workers dealing with radioactive material, called the occupationally exposed, and the general public, or non-occupationally exposed.  For an occupationally exposed worker, such as someone at a nuclear power plant or in nuclear medicine at a hospital (if they’re licensed by the NRC), the limit is 5 rem a year.  Surprisingly, while most nuclear power workers never receive anywhere close to that amount, some workers in the medical field, such as those working with X-ray fluoroscopy machines, are amongst the highest occupationally exposed workers.  Pregnant women who are occupationally exposed may choose to (but are not required to) declare their pregnancy and receive lower dose limits throughout the term of the pregnancy.

For members of the public, the annual limit from the NRC (which is matched by the EPA for areas not covered by NRC guidelines) is 100 mrem.  Licensed facilities have to have programs in place to limit exposure, and be able to demonstrate that procedures are in place that members of the public would not be exceeding those levels. 

7 0
3 years ago
What should my school do? someones been trying to hack the wifi and computers here.
Snezhnost [94]

they should have a fund raiser and collect money and then put up strong fire walls on all the computers

5 0
3 years ago
List &amp; briefly explain 5 benefits of having a Business bank account.
oee [108]

Answer:  down there

Explanation:

Some other benefits come from establishing a business bank account. You can gain access to services that make life easier, such as merchant account and payroll services, free online banking and, importantly, easier access to small business loans.

3 0
3 years ago
Read 2 more answers
1.       Draw a flowchart that sum even number between 0 and 50?​
sveta [45]

Answer:

U just put values here according to ur choice.

There are 24 even numbers between 0 to 50

8 0
3 years ago
Which of the following characteristics differentiates PCM from BWF audio
Marrrta [24]

Answer: A

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Consider a hypothetical microprocessor generating 16-bit addresses with 16-bit data accesses (i.e. each access retrieves 16 bits
    9·1 answer
  • What provision of the Government Paperwork Elimination Act was designed to encourage a paperless society?
    8·2 answers
  • If you want to copy data from one cel to another cell that is several rows down in a worksheet, which method should you use?
    11·1 answer
  • In a distributed database system, the data placement alternative with the highest reliability and availability is Group of answe
    9·1 answer
  • Which component of service-oriented DSS can be defined as data that describes the meaning and structure of business data, as wel
    9·1 answer
  • Describe five examples of civil engineering projects.
    6·1 answer
  • What is a characteristic of tasks in Outlook?
    10·2 answers
  • How many conditions are needed in a while loop that should run until a user guesses the correct number or until they have made f
    8·1 answer
  • What report provides data on how specific sections of a website performed?
    6·1 answer
  • List and describe four services that comprise IT infrastructure, beyond physical devices and software applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!