I want help with this ...
This is the code, and i have taken 4 questions initially... and applied the input method to only question 1 ... i want the input scanner variable of question 1 to be stored in a variable with automatic numbering as the for loops runs till 10 my variable name changes so that i could later call the same question again and compare the answers with if condition ! for example i'm taking 10 inputs for "write 10 colors names" :
i want those inputs.. to be used later again
lets look at it step by step..
1. Show randomly 1 question out of 10.
2. The question's answers should be 10, for example .. write 10 colors, write 10 countries!
3. when the user enters all 10 answers,the program should again display the same question and ask the user to repeat the answers which he/she entered earlier !
4. If the user manages to write the answers in correct sequence in which he entered earlier, the program should add +10 score for each correct sequence answer.
import java.util.Scanner; public class Game { public static void main (String arg[]) { java.util.Random r = new java.util.Random(); int a = r.nextInt(4); int abc[] = null; if (a==0) { System.out.println("Write 10 color names: "); Scanner question = new Scanner(System.in); for(int i=0; i<10; i++) abc[i] = question.nextInt(); } else if (a==1) { System.out.println("Write 10 city names: "); } else if (a==2) { System.out.println("Write 10 contry names: "); } else if (a==3) { System.out.println("Write 10 vegetable names: "); } for (int g=0; g<10;g++) System.out.println(abc[g]); } }