we have 100 questions and 60 students. write a java code that randomly selects 20 questions from 100 questions to 60 students.
1
Expert's answer
2012-12-11T08:34:21-0500
import java.util.Random;
public class RandomQuestions {
public static void main(String args[]) { & int n=1; & Random r = new Random(); & while (n<61) { System.out.print("Number of questions " + n + " is: "); for (int i = 0; i < 20; i++) { System.out.print((r.nextInt(100)+1)+" "); } System.out.println(""); n++; & } } }
Comments
Leave a comment