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
In a non-price rationing system, consumers receive goods and services first-come, first served. Give me an example of a time whe
Anna35 [415]

When someone may be giving away something for free.

7 0
3 years ago
WHO DID IT???????????????????!!!
Gekata [30.6K]

Answer:

orange did it he is sus he took victim's blood and but it on yellow

Explanation:

6 0
3 years ago
Which domain indicated the website is sponsored by the university or college
Pie

The answer is edu. Hope this helps.


3 0
3 years ago
Which group allows you to add notes to your presentation? Animations Presentation views Show Zoom
mel-nik [20]

Answer:

View

Explanation:

With "View", you have the option to add comment(s) which may be important even after the presentation is completed.

Cheera

6 0
3 years ago
Who ever can get me the lyrics to raining tacos will get 46 points + the crown! i want the song!
GenaCL600 [577]

Explanation:

Lyrics

It's raining tacos

From out of the sky

Tacos

No need to ask why

Just open your mouth and close your eyes

It's raining tacos

It's raining tacos

Out in the street

Tacos

All you can eat

Lettuce and shells

Cheese and meat

It's raining tacos

Yum, yum, yum, yum, yumidy yum

It's like a dream

Yum, yum, yum, yum, yumidy yum

Bring your sour cream

Shell

Meat

Lettuce

Cheese

Shell

Meat

Lettuce

Cheese

Shell

Meat

Cheese, cheese, cheese, cheese, cheese

It's raining tacos

Raining tacos

Raining tacos

It's raining tacos

It's raining tacos

Raining tacos

Raining tacos

Shells, meat, lettuce, cheese

It's raining tacos

It's raining tacos

8 0
3 years ago
Read 2 more answers
Other questions:
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • Post secondary education refers to:
    13·1 answer
  • What is a palindrome?
    13·1 answer
  • To get a GIMP file into a different format, you need to
    7·1 answer
  • What type of program installs and gathers personal information, including password and account information, from a computer with
    9·1 answer
  • How can I watch you-tube on my school computer without it being blocked on the computer when it uses Lightspeed Systems Relay or
    7·1 answer
  • Select all the correct answers.
    14·2 answers
  • SimpleScalar is an architectural simulator which enables a study of how different pro-cessor and memory system parameters affect
    6·1 answer
  • What is the difference between business strategies and business models?
    9·1 answer
  • Draw the following diagrams to represent the information system chosen in assignment 1 Context diagram The context diagram is ex
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!