Sorry for the misleading question guys, I know how to generate two random numbers but I want to use them in One JOptionPane input Dialogbox so the user can add the two numbers. Below is my code of what I have done so far I know it's not a lot but I am genuinely stumped on what to do next :-/

Any help is much appreciated! :)

import javax.swing.*;
public class Practical13 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        String input = null;


        double ipt;

       ipt = Double.parseDouble(input);

     ipt =   Math.floor((Math.random() * 10) + 1);

     ipt =   Math.floor((Math.random() * 10) + 1);

     input = JOptionPane.showInputDialog("what is " + ipt );




    }

Lines 16 & 18 generate two numbers, but you have only one variable to strore them, so the second one overwrites the first.
So
You need at least two variables for the two random numbers, then you can use those to display the question (like line 20).
Once you have the user's input you can convert that to a number (like line 14 but in another variable) and compare that with the correct answer.

Got it, Thanks for the help :)

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.