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]
1 year ago
8

Class Main {

Computers and Technology
1 answer:
tatyana61 [14]1 year 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
I need help with Exercise 3.6.7: Sporting Goods Shop in CodeHS. ASAP
attashe74 [19]

Answer:

OK

Explanation:

7 0
3 years ago
In a PERT network, non-critical activities that have little slack need to be monitored closely
kozerog [31]

Answer: b)because near-critical paths could become critical paths with small delays in these activities

Explanation: Program evaluation and review technique(PERT) technique is used for management of the project .The organizing, maintenance,coordination of any task is done by this chart. The non-critical activities need to be observed carefully because they may create near-critical methods which can lead to complexity.

Other options are incorrect because not all activities are equally rather monitoring is done to avoid errors and slack can occur at any path . Small delays can be caused but not complete project can get delayed and there can be risk of complexity rather than being uncompleted.Thus, the correct option is option(b).

6 0
3 years ago
What does a file extension tell you?
kiruha [24]

A. because everyone basically has seen it..

3 0
2 years ago
List the three control problems associated with competingprocesses and briefly define each.
hjlf

Answer and explanation :

the three control problems associated with competing process are

  • MUTUAL EXCLUSION : We know that some resources are shareable and some are not shareable. which means only one process can access the resource at a time this type of resources are called critical resources this code can be access at only one process at a time. the other process if required to access should not be allowed
  • DEADLOCK: this hold the process without complete for example suppose there are two resources R1 and R2 and two process P1 and P2 and P1 use R1 and P2 use R2 but after some time when P1 needs R2 but R2 is not available as it is used by P2 so the all process will be on hold
  • STARVATION : when priorities are given to the process as high priorities and low priorities. And high priorities process always competing  then low priorities process have to wait for very long time this is called starvation
3 0
2 years ago
What happens if you never confirm your facebook account?
OleMash [197]
Nothing, it will just keep sending you annoying notifications that become more and more frequent, i would just confirm it if i were you
5 0
2 years ago
Other questions:
  • Annabella was giving a presentation to a group of 20 real estate agents on
    15·2 answers
  • You have a network that needs 29 subnets while maximizing the number of host addresses available on each subnet. How many bits m
    13·1 answer
  • Generally speaking, manufacturing overhead is applied to production by means of a __________ __________ __________, which is com
    11·2 answers
  • The part of the poppet valve that contacts the valve seat is called the A. face. B. margin. C. head. D. stem.
    6·2 answers
  • Write a function named printtriangle that receives a parameter that holds a non-negative integer value and prints a triangle of
    7·1 answer
  • Purpose Your goal is to create a design for a software interface. You will experience the scope of the design process from brain
    7·1 answer
  • What are the four common tags used on webpages?
    11·1 answer
  • Ayuda necesito 7 objetos que se utilizan en la vida diaria
    8·1 answer
  • How was kapilvastu named​
    11·1 answer
  • Write the simplest statement that prints the following: 3 2 1 Go! python
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!