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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started