Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 6th, 2008, 11:49 PM   #11
cribbageman2500
Newbie
 
Join Date: Apr 2008
Posts: 7
Rep Power: 0 cribbageman2500 is on a distinguished road
Re: New to programming and in over my head!

Sorry about the long delay in my response. Long story short Im now working on it in Java using the net beans IDE Freaky Chris suggested, thank you for that by the way.

As far as the basic logic for the program I was thinking:
Variables:
dice=
thresh=
again=
gen=0
tally=0

num1 = (Math.Random()*10) + 1; add one to gen
if num1 >= again add one to dice and one to tally
else
if num1 >= thresh add one to tally
else
if num1 <= thresh ignore
until
gen=dice
display tally

and thats that, I think that that basic flow of logic should work, its just a matter of putting it all into real code. If you notice any huge errors in my logic please let me know.

Thank you,
Cribbageman
cribbageman2500 is offline   Reply With Quote
Old May 7th, 2008, 12:21 AM   #12
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 189
Rep Power: 1 Jabo is on a distinguished road
Re: New to programming and in over my head!

Well, try coding it and let us know if you get any errors; best way to find them is to run it.

Oh, and if I didn't tell you then another brother would, use CODE TAGS for any code you put here. Code tags look like # above the post editor.
Jabo is offline   Reply With Quote
Old May 7th, 2008, 4:55 AM   #13
tomisinbamgbelu
Programmer
 
Join Date: May 2008
Posts: 2
Rep Power: 0 tomisinbamgbelu is on a distinguished road
Send a message via Yahoo to tomisinbamgbelu
Re: New to programming and in over my head!

k, i don't know if you've solved the javac issue, but one way to do it is to remove it from the environment variable path, because if you hav more than one programmin language on your system, it wont be wise, i suggest you should open a folder on your c drive, in which u shd store your programs, remembering to save it with your classname.java. then on command prompt, type the following to compile nd run the program uv written
cd\
cd "The name of the folder on your c drive in which you saved your work"
then set the path on cmd by typing the directory the jdk is in i.e
set path=c:\programfiles\java\jdk.....\bin
or rather c:\pr"click tab"\j"click tab"\j"tab"\b"tab"
then enter. the tab completes the words for you.
after that type javac, you should get a response.

I hope this helps but if not use an ide, its better, but since you are new using notepad wont be a bad idea.
success
tomisinbamgbelu is offline   Reply With Quote
Old May 7th, 2008, 8:59 PM   #14
cribbageman2500
Newbie
 
Join Date: Apr 2008
Posts: 7
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
Old May 9th, 2008, 8:24 PM   #15
cribbageman2500
Newbie
 
Join Date: Apr 2008
Posts: 7
Rep Power: 0 cribbageman2500 is on a distinguished road
Re: New to programming and in over my head!

Since I am now working in Java, I think it only appropriate to continue this in the Java side of the forums, Thank you all again for the advice and help so far.
cribbageman2500 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:55 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC