Ok, so I just made this account because I'm super stuck. Basically I need to create a math quiz that takes a users input (1 through 12), have it spit out a question, i.e What is 5 x 12? however if the user enters 5, it must randomly generate a question asking the user his 5x tables. i.e What is 5x3? What is 5x7? and so on and he needs to enter the correct answer, after which it will display correct or incorrect. I am having trouble getting the user input part. So far my code allows for him to enter an answer, get correct or incorrect, but they it goes to a seperate timestable, i.e first question will be 5x4, next will be 9x11. I need 5-10 random questions just using his input * and 1-12 as the timestable. What I am asking is how am I able to enter an input value for what times table the quiz is on?

import java.util.*;

public class MathQuizzer{


    public static void main(String[] args)
    {
        Scanner a = new Scanner(System.in);
        int b,right,totalscore,m;
        right = 100; 
        totalscore = 0;
        b = 0;

        do
        {
                double numb = Math.round((Math.pow(10, 2) * Math.random()));
                double numb1 = Math.round((Math.pow(10, 2) * Math.random()));
                double valueFirst;
                double valueSecond;
                valueFirst = numb % 12; 
                valueSecond = numb1 % 12;   //Highest Number
                double answer;
                System.out.print("\nMultiply these two numbers together: ");
                System.out.print(valueFirst);System.out.print(" * ");System.out.println(valueSecond);
                answer = a.nextDouble();

                if(answer == (valueFirst * valueSecond))
                {
                    System.out.println("\nCorrect");
                    right++;
                }

                else
                {
                        System.out.println("\nIncorrect");
                }
            b++;
        }
        while (b < 10 ); //Number of questions to be asked.
        totalscore = right - 100;
        System.out.println("\nYour total score is: " + totalscore );
    }    
}

what do you mean 'times table'? the number of questions you want to receive? or by which number should be one of the numbers to multiply?
anyway, considering the fact we're talking about low numbers here, you should be using int, not double as type for your variables.

timesTable = a.nextInt(); should work just fine

All that code for the random numbers (lines 16-21) looks seriously over the top and thus error-prone. (It's already broken; it returns numbers 0-11. Even after you fix that it still has a higher chance or returning a 1-4 than a 5-12. Not to mention using Math.pow(10,2) instead of 100.0)

If you want a proper random int in the range 1-12 them all you need is the Random class's nextInt method, ie

number = rand.nextInt(12) +1; // where  rand = new Random();
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.