java - Random Generator from String Array -
i'm using java problem. know how randomly take 2 questions out of 3 question string array? lets have 3x5 string array this:
string testbank[][] = {{"what color grass?","a. green","b. red","c. pink","a"}, {"whats first month called?","a. december","b. january","c. march","b"}, {"what shape soccer ball?","a. square","b. flat","c. round","c"}};
the first column question, 2nd-4th column answer choices, , 5th column correct answer. i'm trying figure out how randomly 2 questions these 3 , store 2 questions 1 dimensional array of 2 rows in use joptionpane, outputting, in takes questions 1 dimensional array , shows each question separately 1 one in different windows answer choices included. , after answering 2 questions, tells user score based off how many questions he/she missed.
i'm relatively new java , appreciated if me this.
this how use random class in case. choose random integer, highest number chosen random total number of questions.
random random = new random(); int randomquestion = random.nextint(nrofquestions);
and use randomquestion variable access question matrix: testbank[randomquestion][0]
cheers!
Comments
Post a Comment