0

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 );




    }
2
Contributors
2
Replies
19
Views
2 Years
Discussion Span
Last Post by Gl753
1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.