Question: Using JAVA Problem #2 (5 points): for loop, int, int array, Math.random() Add a new package named hw1p2 to the project FirstName-LastName-HW1 (e.g., John-SmithHW1). 2.

Using JAVA

Problem #2 (5 points): for loop, int, int array, Math.random()

Add a new package named hw1p2 to the project FirstName-LastName-HW1 (e.g., John-SmithHW1).

2. Add a class called ConditioanlFor with main method.

3. Write code for main method of the ConditionalFor class in order to randomly sample 6 numbers from 0, 1, 2, 49 each time you run your program. Complete the template code below to solve this problem.

public class ConditionalFor {

public static void main(String[] args) {

int sampleSize = 6;

int populationSize = 50;

//fill the array named population with 0,1,....... using a loop

//create random sample in population[0], population [1]...... population [5]

for (int i = 0; i< sampleSize; i++) {

//random integer between 1 and 49

//swap elements at indices i and r

}

//print sampled numbers

for (int i = 0; i < sampleSize; i++ ) {

}

System.out.println();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!