hi everyone, james, stultuske
I am trying to build this multiple choice math game, it is my individual assignment and I have less than a month to finish this and i really need the help as quick and as fast as possible

right now the game is not running as how it supposed to run. the game has 3 round with level. round 1 has 4 levels. it is to be put in a loop either a while loop or for loop.

the problems that I am having at the moment. it is jumping from round 1 level 2 and back to round 1 level 1. I know there is lots of logical errors somewhere but I cant seem to pinpoint where in the game the logical errors are.

I also cant seem to get to calculate the scores because you have to calculate it. and print a label

another problem is if the user enter the correct answer the game would continue to run, it will go into a infinite loop but when the user enter the wrong answer it would stop. it is not supposed to do either, when the user enter the wrong answer it supposed to iterate back up to give the user another chance to answer but it doesnt do that.
can some one help me as soon as possible here is my codes.
here is my codes

System.out.println("Hi what is your name");
        username = userinput.next();
        System.out.println(username+" your name is very unique, my dearest");
        System.out.println(username+" how old are you");
        userage = userinput.nextInt();

        if(userage < 8 || userage > 13)
        {
            System.out.println("you have entered an invalid age");
            System.exit(0);
            //this is used for the userage. the game will exit if the wrong age is entered
        }

         //this looping is checking to see if the user enter the correct age
        else if(userage >= 8 && userage <= 13)
        {
            System.out.println(username+" come let's play");
            //this is indicating that the user can play after inputting the correct age

        }

        for(i =1; i<=4; i++) //
        {
             //get the random numbers to generate
            rand  = 1 + randobj.nextInt(25);
            rand2 = 1 + randobj.nextInt(8);
            sum = rand + random2;
            correctans = rand + rand2;
            wrongans = 50 + randobj.nextInt(59);//this is used for generating the wrong ans

            //letting the user know which round and level they are on and what the user are rquired to do
            System.out.println(username+" you are on round 1, level 1 "+" you are required to put the letter to the corresponding answer");
            System.out.println(username+" what is "+ rand+ " + "+ rand2);// asking the user the questions
            i++;

            System.out.println("A:"+ correctans);
            System.out.println("B:"+ wrongans);
            choice = userinput.next().charAt(0);
            //this is the multiplie choice answer which the user would choose the correct answer to the question


        if(choice == 'A')
        {

            System.out.println(username+" that is the correct answer ");
            score = score + 150;
            count = count + 1;
            tries = tries + 1;

        }
         else if (choice == 'B')
        {
            System.out.println(username+" that answer is not correct, plz try again ");
            score = score - 75;
            count = count + 1;
            tries = tries +1;
            System.out.println("the player on round 1, level 1");
            System.out.println(username+" your total score is "+ totalscore);
            break;

        }

        for(i=1; i<=4; i++)
        {
           rand = 1 + randobj.nextInt(25);
           rand2 = 1 + randobj.nextInt(8);
           sum = rand + rand2;
           correctans = rand + rand2;
           wrongans = 50 + randobj.nextInt(59);

           System.out.println(username+" you are still on round 1, level 2 "+ " can you enter the letter that correspond with the correct ans");
           System.out.println(username+ " what is "+ rand+ " + "+rand2);

           System.out.println("A:"+correctans);
           System.out.println("B:"+ wrongans);
           choice = userinput.next().charAt(0);

        if(choice == 'A')
        {
            System.out.println(username+"that answer is quite  correct "+ " excellent!!! keep up the good work");
            score = score - 75;
            count = count + 1;
            break;
        }
        else if(choice == 'B')
        {
            System.out.println(username+" that answer is not quite correct "+ " you can do better, try again");
            score = score + 150;
            count = count +1;
            tries = tries + 1;
            System.out.println("the player on round 1, level 2");
            System.out.println("the total scores is " + totalscore);//this indicating the total score the player made 
            break;
        }

        for(i =1; i <=4; i++)
        {
            //get the rand om numbers
            rand  = 1 + randobj.nextInt(25);
            rand2 = 1 + randobj.nextInt(8);
            sum = rand + rand2;
            correctans = rand + rand2;//this should only generate the correct answers 
            wrongans = 50 + randobj.nextInt(59);//this must only generate wrong numbers 

            System.out.println(username+" you are on round 1 level 3 "+ " you are required to match the letter with the correct answer");
            System.out.println(username+" what is "+ rand+ " + "+rand2);

            System.out.println("A:"+correctans);
            System.out.println("B:"+wrongans);
            choice = userinput.next().charAt(0);
            //
        if(choice == 'A')
        {
            System.out.println("correct is right "+username+" great job");
            score = score + 150;
            count = count + 1;
            tries = tries + 1;
        }
        else if (choice == 'B')
        {
            System.out.println(username+" you know that is not the correctg answer "+ "you can try again");
            score = score - 75;
            count = count + 1;
            tries = tries + 1;
            System.out.println("the players is on round 1 level 3");
            System.out.println("the total score is "+totalscore);
            break;
        }
        for(i =1; i <=4; i++)
        {
            rand  = 1 + randobj.nextInt(25);
            rand2 = 1 + randobj.nextInt(8);
            sum = rand + rand2;
            correctans = rand + rand2;
            wrongans = 50 + randobj.nextInt(59);

            System.out.println(username+" you on round 1, level 4 "+" you are required to match the letter with the correct answer");
            System.out.println(username+"what is"+rand+ " + "+rand2);

            System.out.println("A:"+correctans);
            System.out.println("A:"+wrongans);
            choice = userinput.next().charAt(0);

        if(choice == 'A')
         {
            System.out.println(username+" excellent, correct answer "+ " hope you keep it up!!!");
            score = score + 150;
            count = count + 1;
            tries = tries + 1;
            //this is enquiring whether the user answer is equal to the letter entered   
        }
        else if(choice == 'B')
        {
            System.out.println(username+" you  know that is not the correct answer"+ " please think carefully before you answer");
            score = score - 75;
            count = count + 1;
            tries = tries +1;
            System.out.println("the round is round 1 and level 4");//this will show the current level the player was on
            System.out.println("the total score is "+ totalscore);//this is the total score that the player made for each round
            System.out.println("you have ");
        }

            System.out.println("+*+*+*+*+*+*+ welcome to round 2+*+*+*+*+*+*+*+*");

        for(i =1; i<=4; i++)
        {
            //getting the random numbers
            rand  = 1 + randobj.nextInt(25);
            rand2 = 1 + randobj.nextInt(8);
            sum = rand + rand2;
            correctans = rand + rand2;//this is to hold all the correct answers
            wrongans = 25 + randobj.nextInt(50);//this is to ensure that it must generate only wrong numbers 

            System.out.println(username+" you are on round 2, level 5 "+ " you are required to entered the matching letter that corresponding with the correct answer.");
            System.out.println(username+" what is the difference betwee "+rand+" - "+rand2);
        }
        }
        here is the ouput
        Welcome to Aunty Luz's Multiple Choice Math Game
The game consist of 3 round with 6 level
The age limit is 8 - 13 years 
A player wins the game if all questions are answerred correctly
The player loses the game if they run out of chances
Each player has 4 chances
Each correct answer is rewarded with a maximum of 350 points
Each incorrect answer will lose half of the alloted point given 
A report is submitted at the end of the game
A player only win the game if all 10 question are answered correctly
A player loses the game if the age is entered incorrectly or if the player ran out of the chances given
okay students, I hope that I have made myself very clear
+*+*+*+*+*+*+*+*+welcome to game 1+*+*+*+*+*+*+*+
Hi what is your name
anika
anika your name is very unique, my dearest
anika how old are you
11
anika come let's play
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 19 + 8
A:27
B:95
A
anika that is the correct answer 
anika you are still on round 1, level 2  can you enter the letter that correspond with the correct ans
anika what is 16 + 1
A:17
B:108
A
anikathat answer is quite  correct  excellent!!! keep up the good work
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 15 + 6
A:21
B:81
A
anika that is the correct answer 
anika you are still on round 1, level 2  can you enter the letter that correspond with the correct ans
anika what is 12 + 7
A:19
B:60
A
anikathat answer is quite  correct  excellent!!! keep up the good work
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 9 + 2
A:11
B:65
A
anika that is the correct answer 
anika you are still on round 1, level 2  can you enter the letter that correspond with the correct ans
anika what is 6 + 8
A:14
B:65
A
anikathat answer is quite  correct  excellent!!! keep up the good work
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 11 + 5
A:16
B:107
A
anika that is the correct answer 
anika you are still on round 1, level 2  can you enter the letter that correspond with the correct ans
anika what is 10 + 5
A:15
B:77
A
anikathat answer is quite  correct  excellent!!! keep up the good work
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 17 + 3
A:20
B:107
A
anika that is the correct answer 
anika you are still on round 1, level 2  can you enter the letter that correspond with the correct ans
anika what is 3 + 3
A:6
B:96
A
anikathat answer is quite  correct  excellent!!! keep up the good work
anika you are on round 1, level 1  you are required to put the letter to the corresponding answer
anika what is 5 + 1
A:6
B:89
BUILD STOPPED (total ti

You cut off the output. Why is it saying that the build stopped? Also, there is no terminating output data indicating the score, plus I think that the round + level information shown in the output is wrong.

the game has 3 round with 6 levels
and the instruction say you have to indicate which level and round the user is on

the game keep looping from level one to level two and back to level 1. it is not even going on to level three or level four
how can i fix this logical error

why does the game continue when the use entered the correct answer and stop when the user entered the wrong answer which it should also continue even if the user entered the wrong answer

start with re-reading your code, and remove all that is making it less readable / efficiƫnt.

 else if(userage >= 8 && userage <= 13)
        {
            System.out.println(username+" come let's play");
            //this is indicating that the user can play after inputting the correct age
        }

Since all other flows are covered by the if block, this can be replaced by simply putting:

System.out.println(username+" come let's play");

There is no need at all for the second if.

I don't really understand your logic, but you should not have seperate iterations for each question/level/round, write a list of questions, and iterate over that list, so in the end you'll just end up with one loop.

Since I very little understand of your level/round logic, I also don't immediately understand what your problem is

How do i put tje questions in a list for ewch level and round for it to iterate becuz am really desparate here

As yuh have suggested

Your code is a big mess. You have multiple nested for-loop. Then you keep using the SAME loop index variable (i) in every single loop. Even worse, you manually increase the loop index variable (i) even though it is automatically increased by the for-loop!

What I can tell you now is to remove and simplify your nested for-loop. You need at most 2 for-loop to do the job. First level of for-loop represents each round. Second level of for-loop represents each level.

Better yet, you should draw a flow chart for this program before you even start programming. That way, you would have a guide line of what you are going to do...

Be a part of the DaniWeb community

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