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
How do graphic designers showcase their work?
Luda [366]

They showcase it digitally since their work is done on computers.

6 0
4 years ago
Read 2 more answers
Java uses ____ to implement method lookup.A) a jump tableB) an inheritance treeC) restricted accessD) polymorphism
sashaice [31]

Answer:

D) polymorphism

7 0
4 years ago
Is Bluetooth considered a computing innovation?
Scilla [17]

Answer:

yes it is becauuse through bluetooth i can play cod mobile on my phone wiith my ps4 controller

Explanation:

A Bluetooth device works by using radio waves instead of wires or cables to connect with your cell phone, smartphone or computer. Bluetooth is a wireless short-range communications technology standard found in millions of products we use every day – including headsets, smartphones, laptops and portable speakers.

8 0
3 years ago
You are working as a Solutions Architect for a technology company which is in the process of migrating their applications to AWS
torisob [31]

Answer: Amazon DynamoDB

Explanation: Amazon DynamoDB(Database) is the database that works in quick speed of milliseconds at any area.It has the characteristics like built-in security section, manageable, restoration function, durable etc.These features helps in handling the request of numerous people on large scale everyday.

It can work in multiple region to and can have multiple master .Thus, the database demand mentioned in the question can be completed by using Amazon DynamoDB as it can fulfill the requires of the company.

6 0
4 years ago
Can someone please tel me what switches are in my keyboard? I know they are blye byt what brand?
AlladinOne [14]

Answer:

a s d shift and z and cap lock  if you meant the keys

Explanation:

3 0
3 years ago
Other questions:
  • The purpose of the img element's ________ attribute is to provide a method for a browser to display different images depending o
    7·1 answer
  • A student dissolves some solid sodium hydroxide in a beaker of water.
    5·2 answers
  • Only those who perform music professionally can have a true appreciation for music. True False
    10·2 answers
  • Create an array of strings. Let the user decide how big this array is, but it must have at least 1 element. Prompt them until th
    8·1 answer
  • Suppose you have a primary location in New York City where you main corporate servers are located. Just in case something happen
    5·1 answer
  • A small group of travelers is meeting inside an ancient building, and the travelers need access to the Internet using their mobi
    13·1 answer
  • Two ways in which the media does not reflect the society you live in.
    9·1 answer
  • Draw algorithm and flowchart of multiply A and B​
    10·1 answer
  • Write a program in Python to sum to numbers:<br><br> Urgently needed, please.
    14·1 answer
  • Discusse five advantages of utilising DBMS over a file based system
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!