For some reason I am receiving this error , cannot find symbol, method Math random() not found . If anyone knows why it would be of great help.

int digit1 = (int)(Math.random() * 10);
int digit2 =(int)(Math.random()* 10);

this is supposed to give me two separate random digit variables between 1 and 10 I thought. Whats wrong with my code please help.

nevermind I figured it out , lol

Ok so I need to take the above code and have it only randomly generate numbers between 1-9 . I cannot have zero and I cannot have 10 in it.int digit1=(int) (Math.random()*9) what would I need to do to get rid of zero here and make it 1-9. I think that will make it 0-9 correct?

int digit1 =(int) (Math.random()*10-1); This is my idea can anyone confirm if this will produce random numbers between 1-9?

ok I think I got it .

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.