Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-05-2007, 03:38 PM   #1
Member (9 bit)
 
Foosa's Avatar
 
Join Date: Jan 2006
Location: Statesboro, Ga
Posts: 265
basic Java help

My assignment is to make a program that will ask for a number then multiply it by 1-12. But not allow you to continue until you give the correct answer to each problem.(ie. i pick 1. 1*1=1, 1*2=2, 1*3=3...and so on.)
I got the first part, but I can't get the last part.
I have been working on this far to long. It probley is something easy that im just looking over now. So I'm asking a second pair of eyes to look over it for me.

PHP Code:
 import javax.swing.JOptionPane;

public class 
addloop {
  public static 
void main(String[] args) {

 
int number2 1;

      
String replyString;
//this is where you pick a number and it is turned into a string
     
String numberString JOptionPane.showInputDialog(null"enter any number");
          
int number1 Integer.parseInt(numberString);
//while loop that does all the work
      
while (number1==number1) {
             for (
number2=1;number2<=12;number2++){
                   
String answerString JOptionPane.showInputDialog
                
("What is " number1 " X " number2 "?");
                   
int answer Integer.parseInt(answerString);
                    if (
number1 number2 != answer){};

                                 }
                               
System.exit(0);
                           }

  }

Thanks
Foosa is offline   Reply With Quote
Old 03-05-2007, 04:49 PM   #2
Member (9 bit)
 
Foosa's Avatar
 
Join Date: Jan 2006
Location: Statesboro, Ga
Posts: 265
I knew it was easy, just added that in at the end before the system.exit and got it working.

PHP Code:
while (number1 number2 != answer){ String answer2String JOptionPane.showInputDialog(null,"Try again " +  number1 +" X " +number2 +"?");
                      
int answer2Integer.parseInt(answer2String);
                        
answer answer2;}
                        if (
number1 number2 == answer){} 
Foosa is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java for XP Pro. SP2 ( should I insatll ) Charlie W Windows Legacy Support (XP and earlier) 9 02-27-2007 11:44 PM
Computer Acronyms Floppyman Computer Hardware 156 06-18-2006 06:25 AM
Firefox is great but it just doesn't work well with java antgross@pacbell.net Software Discussion & Support 0 08-04-2005 10:17 PM
Java script works but java applets won't lexi Windows Legacy Support (XP and earlier) 13 09-14-2003 07:11 AM
Microsoft Wins Stay on Order to Add Java morriswindgate General Discussion 7 02-05-2003 09:34 AM


All times are GMT -5. The time now is 07:26 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2