This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-11-13 18:03:01

matthew8092001
Scratcher
Registered: 2010-09-12
Posts: 100+

Java help #3

Recently, I've been trying to figure out how to make this work as a .jar w/o graphics. It's basically an addition practice program xD I'm not sure if this will help, but here's the code:

Code:

import java.util.*;
import java.util.Random; 
public class booleantest {
    public static void main(String[] args){
        int d = 0;
        while (d == 0){
        Random rand = new Random(); 
         int randomnumber = rand.nextInt(1000); 
    boolean fail = true;
        Scanner sum= new Scanner(System.in);
        System.out.println("Please enter the sum of these two numbers:");
        int b = randomnumber;
        Random rand1 = new Random(); 
         int randomnumber1 = rand1.nextInt(1000); 
        int c = randomnumber1;
        System.out.println(b + " and " + c);
        int a = sum.nextInt();
        if (a==(b+c)){
            System.out.println(fail);
        }
        else {
            System.out.println(!fail);
        }
        }
    }
}

It just says that "A java exception has occurred." when I try to execute the exported .jar file.
Thank you in advance!


http://1.bp.blogspot.com/_GVA115I1I8Y/TMGwbJ056kI/AAAAAAAABHs/kpvg0oCKV2g/s1600/happy.gif
lol

Offline

 

#2 2011-11-17 14:42:16

matthew8092001
Scratcher
Registered: 2010-09-12
Posts: 100+

Re: Java help #3

Bumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbumpbump


http://1.bp.blogspot.com/_GVA115I1I8Y/TMGwbJ056kI/AAAAAAAABHs/kpvg0oCKV2g/s1600/happy.gif
lol

Offline

 

Board footer