this all (especially j) but anyone can make their input
it is me again, me and my games and them, i am currently trying to build this game but this one is a counting numbers game. am sure you all must have come across it at some point time. i am trying it again but anyway here goes.
the game has three round where it have to generated random numbers from 1-15 for the first rounds, but it has to generated 4 random questions where the users will have to put it from the smallest to the largest. the second and third rounds it have to generated 1-30 random numbers but it will be 4 questions from those number the users will have to test.

i manage to get round 1 to generated 4 random numbers so that the user can put them from the smallest to the largest and even rounds 3 is the same, i got it to generated random number so that the user can put them from the largest to the smallest.

the problem that I am having and dont understand, is why in the second rounds (round 2) it is generate single number when it should be 4 numbers random
what and where did i go wrong they. here is the codes and output.
how do i fix it. I am not finish coding this. I still have a few thing to add to it i just want to know what d hell did i do they

`````` Scanner keyin = new Scanner (System.in);// scanner object is to get user input
Random randobj = new Random();

String user1name,user2name, welcomemsg, rulesofgame;
int user1age, user2age, numtries = 0;
int scores = 0, sumpts=0;//this is used in order to keep track of scores
int largest = 0, smallest = 0 ;
int ans = 0; //this is used to place all answers
int levcomp = 0;
int i = 0;// is used to keep track of the failed attempt
int count = 0;//used to keep track of the count
int score = 0;
int num1, num2,num3,num4;

System.out.println("Welcome Students, To the School of Hard Knocks!!!!!");
System.out.println("Today we are about to learn to count numbers ");
System.out.println("Lets see how good you both are at counting numbers");
System.out.println("The rules of the game are that both players must between the ages of 6 and 12");
System.out.println("The rules states that each players have a miinimum of three attempts");
System.out.println("The game will be forfeited if each players answer the three questions wrong");
System.out.println("If a player get three question wrong, the other player automatically wins the game");
System.out.println("The numbers are generated randomly, so the players will input the numbers from smallest to largest");
System.out.println("Another one also is from the largest to the smallest");
System.out.println("for every correct answer 50 points are given and for every wrong answer 15 points are deducted");
System.out.println("let us have some fun");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++");

user1name = keyin.next();
System.out.println("my my "+user1name+ "  what a very beautiful name you have there");
System.out.println("now tell me " + user1name+ " how old are you");
user1age = keyin.nextInt();
System.out.println("wow, nice age for a very pretty girl eh");

while(user1age < 5 || user1age > 12)
{
if(user1age < 5 || user1age > 12)
{
System.out.println("dan d police!!!!!! you are to young to play this game  "+user1name);
break;
}

else
{
System.out.println("okay the coast is clear now, come let's play");
count++;
}

}
user2name = keyin.next();
System.out.println(user2name+ " hmm what a unique name you have got there");
System.out.println("so "+user2name+ " can you tell me how old you are");
user2age = keyin.nextInt();
System.out.println("i wonder if I can ever go back to that age again, I guess not");

while(user2age < 5 || user2age > 12)
{
if(user2age <5 || user2age > 12)
{
System.out.println("wow ah guess my instruction of this game wasn't clear enough for you "+ "I am sorry you cannot play");

}
else
{
System.out.println("I guess you did read the rules then, so okay come let play "+ "lets just see how good you are in counting");

}
while(user1age < 5 || user1age > 12 && user2age > 5 ||  user2age > 12)
{
user1age = keyin.nextInt();
user2age = keyin.nextInt();

System.out.println(user1name+" you cannot play this game "+ " neither can you "+ user2name);
System.out.println("did either of you read the rules of this game");
break;

}
while(user1age > 5 || user1age < 12 && user2age > 5 || user2age < 12)
{
System.out.println(user1name+ " plz re-enter the correct age this time");
user1age = keyin.nextInt();
System.out.println(user2name+" plz enter the correct age");
user2age = keyin.nextInt();

System.out.println("aaaaahhhh yessss!!! finally we seem to be getting somewhere"+ "welcome "+user1name+ user2name);
break;
}
System.out.println("****************Welcome playerz to round 1***************");

System.out.println("okay "+user1name+ " ah realize you are very anxious to start "+ " so let us start, you are enter the number from the smallest to the largest in this round");

for(i = 0; i<4; i++)
{
System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()*15));
}
System.out.println(user1name+" start from the smallest and then the largest");

System.out.println("please enter the first smallest number");
num1 = keyin.nextInt();

{
if(ans < num1 || ans > num1)
{
System.out.println("oh wow!!! yuh did it, great, answer is correct, you gain 50 point " + user1name);
numtries += 1;
scores +=50;
sumpts++;
}
else
{
System.out.println("oh no, sorry incorrect answer "+user1name+ " you lose 15 points");
numtries +=1;
scores -=15;
sumpts++;
}
System.out.println(user1name+" plz enter the second smallest number");
num2 = keyin.nextInt();

{
if(ans < num2 || ans > num2)
{
System.out.println("yuh go gurl, yuh get thru, answer is correct "+user1name+"  yuh just earn yourself 50 points");
numtries +=1;
scores+=50;
sumpts++;
}
else
{
System.out.println("ah boy what will you say next "+user1name+ " incorrect answer, come on");
numtries +=1;
scores -=15;
sumpts++;
}
System.out.println(user1name+"now enter the third smallest number");
num3 = keyin.nextInt();

{
if (ans < num3 || ans > num3)
{
System.out.println("excellent!!! excellent, now that was good "+user1name+ " yuh guess correctly");
numtries +=1;
scores += 50;
sumpts++;
}
else
{
System.out.println("not again!!! try again "+user1name+ " lose 15 point for nothing");
numtries +=1;
scores -=15;
sumpts++;

}
System.out.println(user1name+ "please enter the largest number");
num4 = keyin.nextInt();

{
if(ans < num4 || ans > num4)
{
System.out.println("greaaaat!! good job, keep it up " + user1name+ " you did well, answer is correct");
numtries +=1;
scores +=50;
sumpts++;
}

System.out.println(user2name+" it is your turn now, you will be doing the same thing as the other player");

}
for(i = 0; i<4; i++)
{

System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()*15));
}
System.out.println(user2name+" put these numbers from the smallest to the largest");
}
System.out.println(" please enter the first smallest number");
num1 = keyin.nextInt();
}
if(ans < num1  || ans > num1)
{
System.out.println("yes!!! congrats gurl, you got is correct "+user2name+ " you just gain 50 points");
numtries +=1;
scores +=50;
sumpts++;
}
else
{
System.out.println("oh damn!!!! nah man that soo incorrect "+user2name+ " you lose 15 points");
numtries +=1;
scores -=15;
sumpts++;
}
System.out.println(user2name+ " plz enter the second smallest number");
num2 = keyin.nextInt();

if(ans < num2 || ans > num2)
{
System.out.println("ooooh yeah, excellent, correct answer "+user2name+ "  you gain 50 point, keep it up");
numtries +=1;
scores += 50;
sumpts++;
}
else
{
System.out.println("oh what will you think of next "+user2name+ " that answer is incorrect, you lost 15 points");
numtries +=1;
scores -=15;
sumpts++;
}
System.out.println(user2name+" please enter the third smallest number");
num3 = keyin.nextInt();

if(ans < num3 || ans > num3)
{
System.out.println(user2name+" you are doing great, keep it going "+ " you gain 50 point");
numtries +=1;
scores +=50;
sumpts++;
}
else
{
System.out.println(user2name+" what has gone wrong now, that is incorrect "+ " you lose 15 point, learn to count");
numtries +=1;
scores -=15;
sumpts++;
}
System.out.println(user2name+ " please enter the largest numnber");
num4 = keyin.nextInt();

if(ans < num4 || ans > num4)
{
System.out.println(user2name+" sigh, let hear your answer, it is correct "+ " yipeeee!!!, you gain 50 points ");
numtries +=1;
scores +=50;
sumpts++;
}
else
{
System.out.println(user2name+" that is incorrect "+ " I am not even going to say anything, you lost 15 points ");
numtries+=1;
scores-=15;
sumpts++;
}

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

for(i = 0; i<4; i++)
{
System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()*30));

System.out.println(user1name+ "please put the number from the smallest to largest");

System.out.println(user2name+" plz enter the first smallest number");
num1 = keyin.nextInt();

if(ans < num1 || ans > num1)
{
System.out.println(user1name+ " brillant!!! that is correct "+ " you gain 50 points");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user1name+"no that is incorrect "+ " better luck next time, you lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user1name+"please enter the second smallest number");
num2 = keyin.nextInt();

if(ans < num2 || ans > num2)
{
System.out.println(user1name+" yesss!! that is so correct "+ " you gain 50 point");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println("nah man, incorrect answer "+user1name+" you lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user1name+" please enter the third smallest number");
num3 = keyin.nextInt();

if(ans < num3 || ans > num3)
{
System.out.println(user1name+" answer is correct "+user1name+ " keep up the good work, you gain 50");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println("wrong answer "+user1name+ " you lose again 15 pts");
numtries+=1;
scores-=15;
sumpts++;
}
num4 = keyin.nextInt();

if(ans < num4 || ans > num4)
{
System.out.println(user1name+" oooh correct answer keep up the good  work "+ " 50 point you just gain");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user1name+" your guess is correct "+ "  wow!!! you are becoming good at this, 50 point you gain");
numtries +=1;
scores+=50;
sumpts++;
}
System.out.println(user2name+" you are up next "+ "  let see if you can beat the other player score");

for(i = 0; i<4; i++)
{
System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()* 30));

System.out.println(user2name+" plz enter the first smallest number");
num1 = keyin.nextInt();

if(ans < num1 || ans > num1)
{
System.out.println("oh yea correct "+user2name+ " you just gain 50 point, keep up the good work");
numtries +=1;
scores+=50;
sumpts++;
}
System.out.println(user2name+" please enter the second smallest number");
num2 = keyin.nextInt();

if(ans < num2 || ans > num2)
{
System.out.println(user2name+" I love this game, you hit the nail on the head, correct answer");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user2name+ " incorrect answer " + "go and learn to count please, lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user2name+ "please enter the third smallest number");
num3 = keyin.nextInt();

if(ans < num3 || ans > num3)
{
System.out.println(user2name+" ah meh child, you got is righ "+ "you gain 50 point");
numtries+=1;
scores +=50;
sumpts++;
}
else
{
System.out.println(user2name+" incorrect answer "+ "go and learn to count, you lose 15 points");
numtries+=1;
scores+=15;
sumpts++;
}
System.out.println(user2name+" please enter the largest number");
num4 = keyin.nextInt();

if(ans < num4 || ans > num4)
{
System.out.println("kaabooom!! correct answer "+user2name+ "gain 50 point, keep up the good work");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user2name+" do you need some lesson, will be glad to help "+ " that answer is incorrect so you lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}

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

for(i = 0; i<4; i++)
{
System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()*30));
}
System.out.println("ladies this round is going from the largest to smallest number");

System.out.println(user1name+" please enter the first largest number");
num1 = keyin.nextInt();

if(ans < num1 || ans > num1)
{
System.out.println(user1name+" tadaw, yuh go gurl, correct "+ " you gain 50 point");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println("okay stay calm, that answer is not correct okay "+user1name);
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user1name+ " please enter the second smallest number");
num2 = keyin.nextInt();

if(ans < num2 || ans > num2)
{
System.out.println(user1name+" well we are getting somewhere "+ " that is correct, you get 50 point for that");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user1name+" oh jah, that is not the correct answer "+ " please try again, lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user1name+" please enter the third smallest number");
num3 = keyin.nextInt();

if(ans < num3 || ans > num3)
{
System.out.println(user1name+" that is correct, I feel good "+ " 50 point for you");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user1name+" dont disappoint me now okay " + " you can do better, try harder next time but you lose 15 point");
numtries+=1;
scores+=15;
sumpts++;
}

}
System.out.println(user1name+ " please enter the fourth smallest number");
num4 = keyin.nextInt();

if(ans < num4 || ans > num4)
{
System.out.println(user1name+" tadaw, answer is correct "+ " 50 for you, keep up the good work");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user1name+" incorrect answer "+ " you lose 15 point for that, better luck next time");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user2name+"  it is your turn now");

for(i = 0; i<4; i++)
{
System.out.println("Random Number ["+ (i+1) + "] :" + (int)(Math.random()*30));
}
System.out.println(user2name+"please enter the first largest number");
num1 = keyin.nextInt();

if(ans < num1 || ans > num1)
{
System.out.println(user2name+" tadaw, yuh go gurl, correct "+ " you gain 50 point");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println("okay stay calm, that answer is not correct okay "+user2name);
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user2name+" please enter the second smallest number");
num2 = keyin.nextInt();

if(ans < num2 || ans > num2)
{
System.out.println(user2name+" well we are getting somewhere "+ " that is correct, you get 50 point for that");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user2name+" jah no starr, that is not the correct answer "+ " please try again, lose 15 point");
numtries+=1;
scores-=15;
sumpts++;
}
System.out.println(user2name+"please enter the third smallest number");
num3 = keyin.nextInt();

if(ans < num3 || ans > num3)
{
System.out.println(user2name+"that is correct, I feel good "+ " 50 point for you");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user2name+" dont disappoint me now okay " + "you can do better, try harder next time but you lose 15 point");
numtries+=1;
scores+=15;
sumpts++;
}

System.out.println(user2name+ "please enter the fourth smallest number");
num4 = keyin.nextInt();

if(ans < num4 || ans > num4)
{
System.out.println(user2name+" tadaw, answer is correct "+ "50 for you, keep up the good work");
numtries+=1;
scores+=50;
sumpts++;
}
else
{
System.out.println(user2name+" incorrect answer "+ " you lose 15 point for that, better luck next time");
numtries+=1;
scores-=15;
sumpts++;
}
here is the output
alisha
my my alisha  what a very beautiful name you have there
now tell me alisha how old are you
4
wow, nice age for a very pretty girl eh
dan d police!!!!!! you are to young to play this game  alisha
alicia
alicia hmm what a unique name you have got there
so alicia can you tell me how old you are
14
i wonder if I can ever go back to that age again, I guess not
wow ah guess my instruction of this game wasn't clear enough for you I am sorry you cannot play
3
14
alisha you cannot play this game  neither can you alicia
did either of you read the rules of this game
alisha plz re-enter the correct age this time
10
alicia plz enter the correct age
11
aaaaahhhh yessss!!! finally we seem to be getting somewherewelcome alishaalicia
****************Welcome playerz to round 1***************
okay alisha ah realize you are very anxious to start  so let us start, you are enter the number from the smallest to the largest in this round
Random Number [1] :0
Random Number [2] :13
Random Number [3] :2
Random Number [4] :6
alisha start from the smallest and then the largest
please enter the first smallest number
0
oh no, sorry incorrect answer alisha you lose 15 points
alisha plz enter the second smallest number
2
yuh go gurl, yuh get thru, answer is correct alisha  yuh just earn yourself 50 points
alishanow enter the third smallest number
6
excellent!!! excellent, now that was good alisha yuh guess correctly
13
greaaaat!! good job, keep it up alisha you did well, answer is correct
alicia it is your turn now, you will be doing the same thing as the other player
Random Number [1] :3
Random Number [2] :9
Random Number [3] :13
Random Number [4] :4
alicia put these numbers from the smallest to the largest
please enter the first smallest number
3
yes!!! congrats gurl, you got is correct alicia you just gain 50 points
alicia plz enter the second smallest number
4
ooooh yeah, excellent, correct answer alicia  you gain 50 point, keep it up
alicia please enter the third smallest number
9
alicia you are doing great, keep it going  you gain 50 point
alicia please enter the largest numnber
13
alicia sigh, let hear your answer, it is correct  yipeeee!!!, you gain 50 points
***********welcome to round 2*****************
Random Number [1] :1
alishaplease put the number from the smallest to largest
alicia plz enter the first smallest number
1
alisha brillant!!! that is correct you gain 50 points
alishaplease enter the second smallest number
1
alisha yesss!! that is so correct  you gain 50 point
alisha please enter the third smallest number
1
alisha answer is correct alisha keep up the good work, you gain 50
1
alisha oooh correct answer keep up the good  work  50 point you just gain
alicia you are up next   let see if you can beat the other player score
Random Number [1] :2
alicia plz enter the first smallest number
2
oh yea correct alicia you just gain 50 point, keep up the good work
alicia please enter the second smallest number
2
alicia I love this game, you hit the nail on the head, correct answer
aliciaplease enter the third smallest number
2
alicia ah meh child, you got is righ you gain 50 point
alicia please enter the largest number
2
kaabooom!! correct answer aliciagain 50 point, keep up the good work
*****************welcome to round 3***************
Random Number [1] :25
Random Number [2] :21
Random Number [3] :0
Random Number [4] :6
ladies this round is going from the largest to smallest number
alisha please enter the first largest number
25
alisha tadaw, yuh go gurl, correct  you gain 50 point
alisha please enter the second smallest number
21
alisha well we are getting somewhere  that is correct, you get 50 point for that
alisha please enter the third smallest number
6
alisha that is correct, I feel good  50 point for you
alisha please enter the fourth smallest number
0
alisha incorrect answer  you lose 15 point for that, better luck next time
alicia  it is your turn now
Random Number [1] :23
Random Number [2] :12
Random Number [3] :2
Random Number [4] :3
aliciaplease enter the first largest number
23
alicia tadaw, yuh go gurl, correct  you gain 50 point
alicia please enter the second smallest number
12
alicia well we are getting somewhere  that is correct, you get 50 point for that
aliciaplease enter the third smallest number
3
aliciathat is correct, I feel good  50 point for you
aliciaplease enter the fourth smallest number
2
alicia tadaw, answer is correct 50 for you, keep up the good work
BUILD SUCCESSFUL (total time: 2 minutes 9 seconds)
``````

## All 4 Replies

On line 262 I see a left brace. but can't find the matching right brace.

thanks rproffitt
i got it to work

commented: Second pair of eyes. That's all it takes sometimes. But you did the work! +6

my question is; i would like it when the users enter the wrong numbers to give them a chance to re-enter their answers
how do i get to reiterate back. do i have to use a loop and what loop do i have to use.
will the while works or the do while loop or the for loops which one

Copuld be a while or a do/while. Sometimes that's just a question of preference. Try coding both and see which gives the simplest code in your specific application.

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.