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)

Offline
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.

Offline
-bbbbbump------

Offline
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!

Offline
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.

Offline
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.

Offline
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));

Offline