Jump to content

JOptionPane troubles.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
DVeck89

DVeck89

    Newbie

  • Members
  • Pip
  • 1 posts
I'm writing a very simple elementary math program for practice. Actually, I'm basically taking one of my Programming 1 assignments and writing it with GUI's (frames, panes, etc..). One problem; in my old program, I have the following code:

System.out.printf( "How much is %d times %d ? ", gen1, gen2 );
attempt = input.nextInt();

Where gen1 and gen2 are randomly generated numbers. I've been trying to use a JOptionPane to come up with:

number=JOptionPane.showInputDialog("what is %d times %d?",gen1,gen2);
attempt = Integer.parseInt(number);

But it's not working. I'm guessing theres a different way to display %d in gui panes?

#2
Khaotic

Khaotic

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
number=JOptionPane.showInputDialog("what is "+gen1+" times "+gen2+"?");
Check out my site: www.khaoticirc.net