hi
I have a few more days to hand this assignment up, so I need a answer asap. been doing this assignment. . the game has three round with 10 questions. first round 4 questions are randomly generated, second round has also 4 questions that are also randomly generated and the third round has 2 questions that are randomly generated. each rounds there are four levels. first round four levels with a question each generated. second level also four round each with a question generated and third round 2 questions generated.
for each round when a question is generated and the user input the wrong answer, it is supposed to iterate to back to the same level. let say on level one the user input the wrong answer, it supposed to iterate back to level one and stay on level one until the user enters the correct answer and it is also goes for all of the levels and round. the things is it is not even iteration and when it iterate, it iterating and generating the wrong answer with the same question. i have tried everything but I cant seem to find the logical errors and i know there is logical errors. here is the codes that i hve used.
for(i =1; i<=4; i++)
{
//get random numbers
rand = 1 + randobj.nextInt(25);
rand2 = 1 + randobj.nextInt(8);
correctans = rand + rand2;
incorrectans = 25 + randobj.nextInt(50);
//inidicating the level and round the user would start with
System.out.println(playername+" round 1 "+ "level "+ i + " question "+ i + " you are required to match the letter to the corresponding answer");
System.out.println(playername+" please add "+ rand + " + "+ rand2);
//get the multiple choice answer
System.out.println("A:"+correctans);
System.out.println("B:"+incorrectans);
choice = userinput.next().charAt(0);
if(choice == 'A' || choice == 'a')// indicating that any character could be entered
{
System.out.println(playername+" well done kiddo, correct is right, keep it up");
score += score + 650;
System.out.println("round 1");//indicating the round the user is on
System.out.println("level "+ i);//indicating the level the player is on
totalscore += score;//adding the scored
System.out.println("the total score is "+ totalscore);
correctans++;//to count all the correct answer entered
}
else if(choice == 'B' || choice == 'b')
{
System.out.println(playername+" no troll!! not the correct answer, you need to try again");//letting the user know they have entered the wrong answer
score -= score - 225;
System.out.println("round 1");
System.out.println("level "+ i);
totalscore -= score;
System.out.println("the total score is "+ totalscore);
wrongcount++;//to count all the incorrect ans
}
}
i=1;
/*while(wrongans <4)
{
System.out.println(playername+" round 1 "+ "level "+ i +" question "+ i +" you are required to match the letter with the corresponding answer");
System.out.println(playername+" please add "+ 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+" well done kiddo, correct is right, keep it up");
score += score + 650;
System.out.println("round 1");
System.out.println("level "+ i);
totalscore += score;
System.out.println("the total score is "+ totalscore);
correctans++;
}
else if(choice == 'B' || choice == 'b')
{
System.out.println(playername+" no you troll that is incorrect, you need to try again");
score -= score - 225;
System.out.println("round 1");
System.out.println("level "+ i);
totalscore -= score;
System.out.println("the total score is "+ totalscore);
wrongcount++;
}
}
System.out.println("**********************welcome to round 2********************************");
for(i = 5; i<=9; i++)
{
//get random numbers
largest = 1 + randobj.nextInt(25);
smallest = 2 + randobj.nextInt(8);
correctans =largest - smallest;
incorrectans = 25 + randobj.nextInt(50);
for(i =1; i<=4; i++)
{
if(i == 1)
{
smallest = num2;
largest = num1;
}
if(num1 < smallest)
{
smallest = num2;
}
if(num1 > largest)
{
largest = num1;
}
}
System.out.println(playername+"round 2 "+ " level "+ i + " question "+ i + " you are required to match the letter with the matching answer");
System.out.println(playername+" the largest and smallest number entered are: please subtract "+ largest + " - "+ smallest);
System.out.println("A:"+incorrectans);
System.out.println("B:"+correctans);
choice = userinput.next().charAt(0);
if(choice == 'A' || choice == 'a')
{
System.out.println(playername+" that is not cool, the answer is incorrect,you can do better than that");
score -= score -225;
System.out.println("round 2");
System.out.println("level "+ i);
totalscore -= score;
System.out.println("the total score is "+ totalscore);
wrongcount++;
}
else if(choice == 'B' || choice == 'b')
{
System.out.println(playername+" great well done kiddo, that is so correct, you are doing wonderful");
score += score + 650;
System.out.println("round 2");
System.out.println("level "+ i);
totalscore += score;
System.out.println("the total score is "+ totalscore);
correctans++;
}
while(wrongans < 4)
{
System.out.println(playername+" round 2 "+ " level "+ i +" question "+ i + "please match the letter with the correspondng answer");
System.out.println(playername+" the largest and smallest number entered are: please subtrac "+ largest+ " - "+smallest);
System.out.println("A:"+incorrectans);
System.out.println("B:"+correctans);
choice = userinput.next().charAt(0);
if(choice == 'A'|| choice == 'a')
{
System.out.println(playername+" that is not cool, the answer is incorrect, you can do better than that");
score -= score -225;
System.out.println("round 2");
System.out.println("level "+ i);
totalscore -= score;
System.out.println("the total score is "+ totalscore);
wrongcount++;
}
else if(choice == 'B' || choice == 'b')
{
System.out.println(playername+" great job, well done kiddo, that is so correct, you are doing wonderful");
score += score + 650;
System.out.println("round 2");
System.out.println("level "+ i);
totalscore += score;
System.out.println("the total score "+ totalscore);
correctans++;
}
}
}
System.out.println("********************welcome to round 3*******************************");
for(i = 9; i<=10; i++)
{
//get the random numbers
numerator = 1 + randobj.nextInt(25);
denominator = 2 + randobj.nextInt(8);
num1 = 2 + randobj.nextInt(20);
num2 = 2 + randobj.nextInt(25);
correctans = numerator = denominator * num2;
correctans = numerator / denominator;
incorrectans = 25 + randobj.nextInt(50);
if(numerator %2!=denominator)
{
//letting the players know of the round and level they will be starting at
System.out.println(playername+" round 3 "+" level "+ i +" question "+ i + " you are to match the letter with the matching answer");
System.out.println(playername+" please divide "+ numerator + " / "+ denominator);
System.out.println("A:"+correctans);
System.out.println("B:"+incorrectans);
choice = userinput.next().charAt(0);
if(choice == 'A' || choice == 'a')
{
System.out.println(playername+" yea man daiz wey we taling about, that is correct, a job well done");
score += score +650;
System.out.println("round 3");
System.out.println("level "+ i);
totalscore += score;
System.out.println("the total score is "+ totalscore);
correctans++;
}
else if(choice == 'B' || choice == 'a')
{
System.out.println(playername+" no that is not the correct answer, you need to buck up on your maths");
score -= score - 225;
System.out.println("round 1");
System.out.println("level "+ i);
totalscore -= score;
System.out.println("the total score is "+ totalscore);
wrongcount++;
}
while(wrongans < 4)
{
System.out.println(playername+" round 3 "+ " level "+ i +" question "+ i + " you are required to match the letter with the corresponding answer");
System.out.println(playername+" please divide "+ numerator + " / "+ denominator);
System.out.println("A:"+correctans);
System.out.println("B:"+incorrectans);
choice = userinput.next().charAt(0);
if(choice == 'A' || choice == 'a')//this indicationg any character can be used
{
System.out.println(playername+" aaawwwsome that is so correct, you are doing very good keep it up");
score += score +650;
System.out.println("round 3");
System.out.println("level "+ i);
totalscore += score;
System.out.println("the total score is "+ totalscore);
correctans++;//thi counting all the correct ans
}
else if(choice == 'B' || choice == 'b')
{
System.out.println(playername+" aww come on!!! you can do better, that is not correct");
score -= score - 225;
System.out.println("round 3");
System.out.println("level "+ i);
totalscore -=score;
System.out.println("the total score "+ totalscore);
wrongcount++;
}
if(correctans > totalscore)
{
System.out.println(playername+" you won the game");
}
else if(correctans < totalscore)
{
System.out.println(playername+" you lose the game");
}
else if(correctans == totalscore)
{
System.out.println(playername+" game draw");
}
totalscore = correctans + totalscore;
System.out.println("the total score is "+ totalscore);
System.out.println("the player name is "+ playername);
System.out.println("the player age is "+ playerage);
System.out.println("the question is "+ question);*/

