hi all (james)

i have another question: if yuh want to use the random numbers, it goes like dis: random generator = new random() or it have the math.random right my questions are

how do u get to generate the 2, 3, 4- times table,

0

hi all (james)

i have another question: if yuh want to use the random numbers, it goes like dis: random generator = new random() or it have the math.random right my questions are

how do u get to generate the 2, 3, 4- times table,

0

hi james

what I meant is that I know random generator = new random would drop random numbers, the question is there a way that u can get to drop numbers that would be the 2 times, tables along with the rest of tables

ah know it may sound kinda weird to you and u probably thinking i am crazy

0

hi james

it is that I am doing over the multiplication game program in java right, and it has three levels right, easy meduim and hard.

the difficult-level easy has three rounds with

4 random questions from the 2 times table- this is round 1,

4 random questions from the 3 times table - this is round 2

4 random questions from the 4 times table -this is round 3

difficult level meduim has 4 game round

3 random questions from the 5 times table - this is round 1

3 random questions from the 6 times table - this is round 2

3 random questions from the 7 times table - this is round 3

3 random questiosn from the 8 times table - this is round 4

difficult level hard has 4 games round

3 random question from the 9 times table - this is round 1

3 random questions from the 10 times table - this is round 2

3 random questions from the 11 times table - this is round 3

3 random questions from the 12 times table - this is round 4

how do i get the random generator to do exactly that. i manage to get to generate some random number to multiply, it randomly generating from the 13 and sometimes the 14 times table which is what i dont want exactly. can you guide me in the right direction as to how do get it to do exaclty dat

0

So all you need is to generate random ints in the range 2-12?

Create a Random and call its nextInt method as often as needed. nextInt(n) generates a number between 0 and (n-1) inclusive, so you need a tiny amount of arithmetic to get 2-n inclusive, eg

Random r = new Random();

int aNumber = r.nextInt(n-1) +2; //random number between 0 and n inclusive

0

thank you very much j, sometimes ah wish that i can actually see u

0

and why would i be, let me be the judge of that j. but thanks anyway

0

hi j

i have tried it both ways and this is my results.

```
String welcomemsg, welcome="";
int count =0, user1age, user2age;
int sum_scores_user1name=0; // depend on the number of chances given
int corrans = 0, incorrans =0; // to hold all of the correct answer
int scores1 = 0; // to keep track of the scores made in the game
int wrongans =0; // to hold the number of wrong answer entered
int countlevel=0; // which level of the game the user choose to play
int passmark = 50, rand1, rand2,passmark_user1name, passmark_user2name;
int userans = 0, correct = 0;
int ans = 0, n = 2, ques = 0;
String user1name ;
String user2name;
int num1 = 0, num2 =0, ans1;
// declaring of the variables that will be use during the program
// introduction and rules of the game to the players
System.out.println("Hi everyone, welcome to Aunty Bae Multiplication quiz!!!!!!!");
System.out.println("Here is where you learn your multiplication table");
System.out.println("Rules of the games");
System.out.println("Student should be between the ages of 6 to 12 years old");
System.out.println("Each student are given three chances each");
System.out.println("the game will be forfeited if the criteria doesnt met");
System.out.println("***************************************************************");
System.out.println("hi what is your name");
user1name = userinput.next();
System.out.println("my what a beautiful name you have got there "+ user1name);
System.out.println("now can you tell me how old are you "+ user1name);
user1age = userinput.nextInt();
System.out.println("what I wouldnt do to be that age again");
while(user1age < 6 || user1age < 12)
{
System.out.println("wow, incorrect age " + user1name);
System.out.println("you cannot play this game");
break;
}
while(user1age > 6 || user1age < 12)
{
System.out.println("please re-enter the correct age this time "+ user1name);
user1age = userinput.nextInt();
System.out.println("nice, lovely, now we are getting somewheere, you can play");
break;
}
System.out.println("hi what is your name");
user2name = userinput.next();
System.out.println("what a unique name you have there "+ user2name);
System.out.println("now can you tell me your age " + user2name);
user2age = userinput.nextInt();
System.out.println("I would surely give anything to go back to my childhoold days");
while(user2age < 6 || user2age > 12)
{
System.out.println("okay, stay calm, stay cam, dont blow your top, incorrect age "+user2name);
System.out.println("boom!!!! you cannot play this game");
break;
}
while(user2age > 6 || user2age < 12)
{
System.out.println("okay I am calm now, please re-enter your age again "+user2name);
user2age = userinput.nextInt();
System.out.println("tadaw!!! yuh in d game, come play");
break;
}
System.out.println("welcome students to round 1 " + user1name + " and " + user2name);
System.out.println(" which one of you, students would like to go first will it be you "+user1name + " or "+ user2name);
Random randgen = new Random();
int number = randgen.nextInt(12)+ 2;
{
System.out.println(user1name+" we are going to start with you "+ "what is "+ num1+ "*"+ num2+ "=?");
ans = userinput.nextInt();
if(ans == num1 * num2)
{
System.out.println("excellent!!! correct "+user1name+ " keep up the good work "+ "you just scored 250 points");
corrans+= 250;
scores1++;
}
else if(ans != num1 * num2)
{
System.out.println("oop!! incorrect answer "+user1name+ " try again");
wrongans-= 125;
scores1++;
}
System.out.println(user2name+" hi it is your turn");
}
here is the output
hi what is your name
larissa
my what a beautiful name you have got there larissa
now can you tell me how old are you larissa
5
what I wouldnt do to be that age again
wow, incorrect age larissa
you cannot play this game
please re-enter the correct age this time larissa
10
nice, lovely, now we are getting somewheere, you can play
hi what is your name
kadeem
what a unique name you have there kadeem
now can you tell me your age kadeem
14
I would surely give anything to go back to my childhoold days
okay, stay calm, stay cam, dont blow your top, incorrect age kadeem
boom!!!! you cannot play this game
okay I am calm now, please re-enter your age again kadeem
11
tadaw!!! yuh in d game, come play
welcome students to round 1 larissa and kadeem
I have a question, which one of you would like to go first will it be you larissa or kadeem
larissa we are going to start with you what is 0*0=?
1
oop!! incorrect answer larissa try again
kadeem hi it is your turn
BUILD SUCCESSFUL (total time: 30 seconds)
```

am only getting zero right through, no other numbers are generating, why is that. tried it both ways.

0

Line 77 you generate one random number "number"

Then you ask the user about two completely different numbers "num1" and "num2" that you have not generated.

This topic has been dead for over six months. Start a new discussion instead.

Recommended Topics

It works fine, but my question is how do l enable ...

Hello Everyone,

I have developed a DBMS and I want to store the credentials for server, and user name securely so that the users don't have to enter the password ...