Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

What was the role of the Pound Conference in encouraging ADR?

Answered: 1 week ago