PDA

View Full Version : [SOLVED] java help



aszxcv
January 8th, 2009, 02:33 AM
my code



public class gohome {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int x = Math.round (Math.PI * 20.0);
System.out.println(x);

}

}






error messages



found : long
required: int
int x = Math.round (Math.PI * 20.0);
1 error
BUILD FAILED (total time: 0 seconds)

badperson
January 8th, 2009, 03:00 AM
Hi,

the expression you have is pi times 20.0, that's not an int value.

change to

long x = Math.round (Math.PI * 20.0);
that should work. (it also might be a double, not sure...)
bp

aszxcv
January 8th, 2009, 03:02 AM
i solved it i was to use (int) typecast