hi everyone

oh gosh imma know allyuh probably get fed up of me. I am building this game, well it is the same game as in my last post. I decided to delete everything and do it over just to figure out my logical error and boi when i really think i did, i could not have been more wrong.

i finally have a fair idea on how the game should be build. it have 3 game round. and in each rounds. they are 10 random numbers should be generated.
round 1 must have 4 question. random numbers which should be randomized. it is a multiple choice game(round 1 - addition round)
round 2 must also have 4 question which also should be randomized (round 2- subtract round)
round 3 must have 2 question random numbers which should be randomed (round 3 - division round)
i figure out how to get the levels for round one: round 1 levels should be from 1-4, round 2 levels - 5-8 and round 3 level 9-10
i figure out how to get round 1 levels from 1-4, it is round 2 and 3 levels iam trying how to get it to say 5-8 and 9-10

another problem am having is that it have logical errors because it is not running how it supposed to run. I used a for loop where it supposed to generate for 4 question from the random numbers. but is not generated the 4 question, it give only one question and it jump to round 2. i
it supposed to show the scores that i hve added and the total scores, it is not doing that, it just jump straight to round 2.
can you tell me where and how i can fix this because i have less than a few weeks to hand in. i havnt finished coding as yet, was just checking ever so often to see how it is running. here is my codes and the out put.

System.out.println("Welcome to Aunty Luz's Multiple Choice Math Game");
        System.out.println("The game consist of 3 round with 6 level");
        System.out.println("The age limit is 8 - 13 years ");
        System.out.println("A player wins the game if all questions are answerred correctly");
        System.out.println("The player loses the game if they run out of chances");
        System.out.println("Each player has 4 chances");
        System.out.println("Each correct answer is rewarded with a maximum of 350 points");
        System.out.println("Each incorrect answer will lose half of the alloted point given ");
        System.out.println("A report is submitted at the end of the game");
        System.out.println("A player only win the game if all 10 question are answered correctly");
        System.out.println("A player loses the game if the age is entered incorrectly or if the player ran out of the chances given");
        System.out.println("okay students, I hope that I have made myself very clear");
        //input the rules and regulation of the game 


        System.out.println("+*+*+*+*+*+*+*+*+welcome to the game 1+*+*+*+*+*+*+*+");

        System.out.println("Hi what is your name");
        playername = userinput.next();
        System.out.println(playername+" your name is very unique, my dearest");
        System.out.println(playername+" how old are you");
        playerage = userinput.nextInt();
        //asking for the user name and age

        if(playerage < 8 || playerage > 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(playerage >= 8 && playerage <= 13)
        {
            System.out.println(playername+" come let's play");
            //this is indicating that the user can play after inputting the correct age
        }
        for(i = 1; i <=4; i++)//getting the four numbers to be generated
        {
            //get random numbers
            rand  = 1 + randobj.nextInt(25);
            rand2 = 1 + randobj.nextInt(8);
            correctans = rand + rand2;//this is to hold all the correct answer
            incorrectans = 25 + randobj.nextInt(50);//this is to hold all the wrong answer

            System.out.println(playername+" round 1,"+ " level "+ i+ " Question "+i+ " can you match the letter to the correct answer");
            System.out.println(playername+" what is "+rand+ " + "+ rand2);

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

        if(choice == 'A' || choice == 'a')
        {
            System.out.println(playername+" yipeeee!!! that's correct "+ "keep up the good work");
            score = score + 350;
            sum_pos = sum_pos + 1;
            totalscore += score;
            System.out.println("round 1");
            System.out.println("level 1");
            question_count = question_count + 1;
            System.out.println("the total score is "+ totalscore);
            tries++;
        }
        else if(choice == 'B'|| choice == 'b')
        {
            System.out.println(playername+" Beeeeeeeeep!! you are wrong "+ "plz try again");
            score = score -185;
            sumneg = sumneg +1;
            totalscore -= score;
            System.out.println("round 1");
            System.out.println("level 1");
            System.out.println("the total score is "+ totalscore);
            tries++;
        }

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

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

            System.out.println(playername+" round 2 "+ "level "+ i + " Question "+ i+ " you are kindly ask to match the letter to the correct answer");
            System.out.println(playername+" what is the difference between "+rand+ " - "+ rand2);

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

        if(choice == 'A' || choice == 'a')
        {
            System.out.println(playername+" awesome!!!! that is correct "+" you are doing great!! "+ " keep up the good work");
            score = score + 350;
            sum_pos = sum_pos + 1;
            question_count = question_count + 1;
            totalscore += score;
            System.out.println("round 2");
            System.out.println("level 5");
            System.out.println("the total score "+ totalscore);
            tries++;

        }
        else if(choice == 'B'|| choice == 'b')
        {
            System.out.println(playername+" bleep!!! you are wrong "+ " come one, try again");
            score = score - 185;
            sumneg = sumneg +1;
            count = count + 1;
            totalscore -= score;
            System.out.println("round 2");
            System.out.println("level 5");
            System.out.println("the total score is "+ totalscore);
            tries++;
        }


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

            rand  = 1 + randobj.nextInt(25);
            rand2 = 2 + randobj.nextInt(7);
            correctans = rand / rand2;
            incorrectans = 25 + randobj.nextInt(50);

            System.out.println(playername+" round 3 "+ "level "+ i + " Question "+ i+ " you are kindly ask to match the letter to the correct answer");
            System.out.println(playername+" what is the difference between "+rand+ " / "+ rand2);

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

        if(choice == 'A'|| choice == 'a')
        {
            System.out.println(playername+" DITTO!!! correct is right "+ "excellent job!!!");
            score = score + 380;
            sum_pos = sum_pos + 1;
            question_count = question_count + 1;
            System.out.println("round 3");
            System.out.println("");
            totalscore += score;
            System.out.println("the total score is "+ totalscore);

        }
        else if(choice == 'B'|| choice == 'b')
        {
            System.out.println(playername+" DING DONG you are wrong!!!! "+ " this doesnt look good");
            score = score - 185;
            sumneg = sumneg + 1;
            totalscore -= score;
            System.out.println("round 3");
            System.out.println("");
            System.out.println("the total score is " + totalscore);
            tries++;
        }

        }

            here is the output
            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 the game 1+*+*+*+*+*+*+*+
Hi what is your name
keiron
keiron your name is very unique, my dearest
keiron how old are you
11
keiron come let's play
keiron round 1, level 1 Question 1 can you match the letter to the correct answer
keiron what is 3 + 6
A:9
B:29
A
keiron yipeeee!!! that's correct keep up the good work
round 1
level 1
the total score is 350
+*+*+*+*+*+*+*+*+*+*+*welcome to round 2+*+*+*+*+*+*+
keiron round 2 level 1 Question 1 you are kindly ask to match the letter to the correct answer
keiron what is the difference between 11 - 4
A:48
B:7
BUILD STOPPED (total time: 26 seconds)

why is it jumping to round 2 after running 1 question from round 1 when it should generate 4 question first before going on to round 2.
the same should be for round 2. it has to generate 4 question before going on to round 3 but it is not doing what it is supposed to.
looking forward to a favourable reply thanks in advance

again: this entire block

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

can be replaced by:

   else 
        {
            System.out.println(playername+" come let's play");
            //this is indicating that the user can play after inputting the correct age
        }

or even by

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

or, better yet, completely ommitted, for the simple reason that all other (invalid) cases are handled in the if block.

Also, your logic is pretty bad. Whether the correct answer is A or B is not something you should hardcode, but that should be generated by your code.

Your round 2 is embedded in your round 1.

The start of your second for-loop (round 2) is right after the closing bracket of

else if(choice == 'B'|| choice == 'b')
        {
            System.out.println(playername+" Beeeeeeeeep!! you are wrong "+ "plz try again");
            score = score -185;
            sumneg = sumneg +1;
            totalscore -= score;
            System.out.println("round 1");
            System.out.println("level 1");
            System.out.println("the total score is "+ totalscore);
            tries++;
        }
        System.out.println("+*+*+*+*+*+*+*+*+*+*+*welcome to round 2+*+*+*+*+*+*+");
        for(i =1; i<=4;i++)
        {

So, round 2 is not started after finishing round 1, but after finishing handling answer 'B' (which is part of round 1).

A few pointers: don't create a new loop for each round. Generate everything in a list (or even a multi dimensional one), and have one loop iterating over that.
Also: as stated before, don't hardcode which answer is the correct one or not. That kind of defeats the purpose of the game.

how do you generate a list or multi dimensional list and i used this:

 System.out.println(playername+" round 1,"+ " level "+ i+ " Question "+i+ " can you match the letter to the correct answer");

to get it to say: round 1, level 1 - 4 Question 1 - 4 in the first round.

how can i get this to say: round 2 level 5 -8, Question 1 -4 and the same will be for round 3:
round 3 level 9-10 questions 1 -2

what do i do to remove it from round 1

you put the closing bracket of the first for loop, before you initiate the second round.

If you simply take every block of code iside those loops/ifs that is more than 3 lines long and put those in separate well-named methods then you will be able to see your overall logic flow properly

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.