View Single Post
Old May 7th, 2008, 8:59 PM   #14
cribbageman2500
Newbie
 
Join Date: Apr 2008
Posts: 8
Rep Power: 0 cribbageman2500 is on a distinguished road
Re: New to programming and in over my head!

OK, the code so far is...

java Syntax (Toggle Plain Text)
  1. import java.util.*;
  2. import javax.swing.*;
  3.  
  4. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  5. int gen, tally, num1;
  6. double dice = Double.parseDouble(jTextField1.getText());
  7. double thresh = Double.parseDouble(jTextField2.getText());
  8. double again = Double.parseDouble(jTextField3.getText());
  9. gen=(0);
  10. tally=(0);
  11. {num1 = (int) ((Math.random() * 10) + 1);
  12. {gen ++;}
  13. while (gen<dice)
  14. {if (num1>=again)
  15. {dice ++;
  16. tally ++;}
  17. else
  18. if (num1>=thresh)
  19. {tally++;}
  20. else
  21. if (num1<thresh)
  22. jTextField4.setText(String.valueOf(tally));
  23. }
  24. }
  25.  
  26. }

As you might be able to tell, I'm attempting to run this in a GUI, because Net Beans makes it very easy to do GUI work. i have for simplicities sake left the GUI code out. That being said, I was able to successfully compile the program, but when i attempted to run it, with variables in all necessary fields, the program lagged heavily and the error "java.lang.NullPointerException" popped up in the output dialog box in Net Beans.

Any ideas are always welcome.
Thank You,
Cribbageman
cribbageman2500 is offline   Reply With Quote