• Log in or sign up for an account here: https://www.sythe.org/login

Programming Stories

Status
Not open for further replies.
Joined
Feb 11, 2007
Sythe Gold
0
Messages
1,478
Tell horror stories or brag about success or just rant about languages.

Ill start with mine:

I've been programming in Java for about 4 days now, 2 days ago I was doing a programming exercises that came with the free book that I got off the internet. It was to simulate dice rolls and see how many rolls it took to get snake eyes. I set at my laptop for 2 hours trying to figure it out. Then today I went back and I realized I had to use a while loop. -Facepalm-
 
I've been programming in Java for about 4 days now, 2 days ago I was doing a programming exercises that came with the free book that I got off the internet. It was to simulate dice rolls and see how many rolls it took to get snake eyes. I set at my laptop for 2 hours trying to figure it out. Then today I went back and I realized I had to use a while loop. -Facepalm-

Code:
import java.lang.reflect.*;

class DiceTest {

    private static int random() {
        return (int)(Math.random() * 6);
    }

    public static void main(String[] args) {
        int tries = 0;
        while(true) {
            tries++;
            int dice1 = random();
            int dice2 = random();
            if((dice1 == 1) && (dice2 == 1)) {
                System.out.println("Snake eyes on try #" + tries);
                break;
            }
	}
    }

}
That took you over 2 hours? Lol..

Let's see...I got started with HTML when I was in 4th grade because I wanted to make my own website (I have no idea why). In 5th grade, I got a book on game programming which was with blitz basic (a waste of my time, in which I learned nothing). In 6th grade, I got familiar with Java with RSPS (I was so bad, I couldn't create a HelloWorld Program on my own >__<). Then November of last year I started up with Java again. I learned stuff pretty quickly, also learned some C# (very similar to Java), as well as XML (markup, not programming language), php (scripting, not programming), and here I am now.
 
Code:
import java.lang.reflect.*;

class DiceTest {

    private static int random() {
        return (int)(Math.random() * 6);
    }

    public static void main(String[] args) {
        int tries = 0;
        while(true) {
            tries++;
            int dice1 = random();
            int dice2 = random();
            if((dice1 == 1) && (dice2 == 1)) {
                System.out.println("Snake eyes on try #" + tries);
                break;
            }
	}
    }

}
That took you over 2 hours? Lol..

Let's see...I got started with HTML when I was in 4th grade because I wanted to make my own website (I have no idea why). In 5th grade, I got a book on game programming which was with blitz basic (a waste of my time, in which I learned nothing). In 6th grade, I got familiar with Java with RSPS (I was so bad, I couldn't create a HelloWorld Program on my own >__<). Then November of last year I started up with Java again. I learned stuff pretty quickly, also learned some C# (very similar to Java), as well as XML (markup, not programming language), php (scripting, not programming), and here I am now.

rofl i would say age explains your ineptitude but then again at your age i was better
 
I'm sure if you read the book it would give you a general idea of how to do it...if not, buy a better book. lol
 
Jimmy.. I understand that was probably fairly fast and rough, but your random method sucks =P

You shouldn't rely on integer truncation, that's basically like setting each number generated to its floor value instead of actually rounding it. Which means you'll get a disproportionate amount of low numbers XD
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top