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

#1 2011-06-04 08:47:49

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

Java help

I basically don't really program in scratch anymore, i use JCreator which is this java thing. Anyway, I'm trying to assign the user input to a variable, but it's not working. Here's the code:

import java.io.* ;

public class Matthew {
   
    public static void main(String[] args) {
        scanner scan = new scanner(System.in);a



        System.out.println("enter a number:");
        int y = scan.nextInt();
        double x=(Math.PI);
       
       
        System.out.println("Assuming that the radius of the circle is y, the area of the circle is "+(Math.pow(x,2)*y)+" square units.");
       
    }
}
Any ideas on what's wrong here?

Last edited by matthew8092001 (2011-06-04 08:48:19)


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

Offline

 

#2 2011-06-04 08:50:41

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Java help

This help?

Offline

 

#3 2011-06-04 08:55:09

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

Re: Java help

ProgrammingFreak wrote:

This help?

It helped, but then after I type in a number and hit "enter," error messages keep on popping up and going like "ExceptionDetectorError, "Publicclass not found on port 80", blah, blah, blah. I'm trying to look for a straightforward command. It might not be possible, but I believe that you can do pretty much anything with Java.


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

Offline

 

#4 2011-06-04 09:08:13

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

Re: Java help

-bbbbbump------


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

Offline

 

#5 2011-06-04 11:59:56

rabbit1131
Scratcher
Registered: 2009-10-16
Posts: 1000+

Re: Java help

Code:

import java.util.*;

public class Matthew {
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);



        System.out.println("enter a number:");
        int y = scan.nextInt();
        double x=(Math.PI);
        
        
        System.out.println("Assuming that the radius of the circle is y, the area of the circle is "+(Math.pow(x,2)*y)+" square units.");
        
    }
}

This code works!


The Intergalactic Adventures of Revesilia! I hope you will partake in this gigantic undertaking, to build the sequel to the hit map The Adventures of Revesilia! The Intergalactic Adventures of Revesilia Map Builders Application thread! http://internetometer.com/image/35004.png

Offline

 

#6 2011-06-04 12:05:04

rabbit1131
Scratcher
Registered: 2009-10-16
Posts: 1000+

Re: Java help

I made it work. You were importaing java.io, needed to be java.util and some other minor things. But, run that code and it will work.


The Intergalactic Adventures of Revesilia! I hope you will partake in this gigantic undertaking, to build the sequel to the hit map The Adventures of Revesilia! The Intergalactic Adventures of Revesilia Map Builders Application thread! http://internetometer.com/image/35004.png

Offline

 

#7 2011-06-05 07:47:25

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

Re: Java help

rabbit1131 wrote:

Code:

import java.util.*;

public class Matthew {
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);



        System.out.println("enter a number:");
        int y = scan.nextInt();
        double x=(Math.PI);
        
        
        System.out.println("Assuming that the radius of the circle is y, the area of the circle is "+(Math.pow(x,2)*y)+" square units.");
        
    }
}

This code works!

Thanks.


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

Offline

 

#8 2011-06-05 09:07:52

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

Re: Java help

More help please?
I have all the public static void stuff and the imports down in case you're wondering if I'm a java n00b, which I am.
It doesn't seem to work.
System.out.println("Enter something random:");
Scanner scan2 = new Scanner(System.in);
String z = scan2.toString();
System.out.println("You're a " + (z));


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

Offline

 

Board footer