int randnum;
            randnum = (int)(Math.random() * 15 + 1);

            String p1, p2, welcomemsg, rulesofgame;
            int age, targnum = 0;
            int r1, r2,r3,r4,r5,r6;
            int largest, smallest, numtries = 0;
            char ans, y;
            int addscores, numoftries, numofrounds = 0, questions = 0, count; 
            String userinput;

            for(count = 1; count<3; count++){

            System.out.println("Welcome Students, To the School of Hard Knocks!!!!! "+ "\n "+ "Today we are about to learn to count numbers " + "\n " + "I am looking for two players to play a game of counting numbers, who is going to be the two players? " + "\n " + "K'Ionda, Lorraine, anyone, okay lets take Shia and Lorraine to play " + "\n "+ "Lets see how good you both are at counting numbers");
            welcomemsg = sentin.nextLine(); // displaying a welcome message to the students

            System.out.println("The rules of the game goes like this, the game is to be played by two students should be between the ages of 5 and 10 " + "\n "+ "K'Ionda and Lorriane will be competing against each other and they are both between the required age limit " + "\n" + "the winner takes all, so lets get this game cracking!!!!!");
            welcomemsg = sentin.nextLine(); //getting them fimarilize with the rules of the game and what are expected from them

            System.out.println("player1 what is your name?"); // asking for the students name
            p1 =; // reading the student name

            System.out.println("player1 how old are you?"); //asking for the student age
            age = sentin.nextInt(); // reading the student age

            System.out.println("player2 what is your name?"); //asking for the student name
            p2 =; // reading the student name

            System.out.println("player2 how old are you?"); // asking for the student age
            age = sentin.nextInt(); // reading the student age

            System.out.println("enter round 1");
            int num = 1 + (int) (Math.random()* 15 + 1);
            userinput = sentin.nextLine();

            while(count != num){

            // this provide the user to pick a choice of either continue to play or to quit
           System.out.println("Do you wish to quit or continue  y/n");
           if(ans.equalsIgnoreCase('y')) I am getting a char cannot be deferrenced

how do I get this to work properly and how do i fix these codes.
can u tell me what is wrong with my codes and them. what do i have to do to get to say if the players chose to say yes to continue, how do get to write the code properly without getting the char cannot be deferenced, i tried it every way possible

You only print the query about continuing or not (line 47), but you take no input to test in the ans variable (line 48).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.