I have recently written the following code:
import java.util.Scanner;
import java.lang.Math;
public class Circle{
public static void main(String[] args){
int d;
int a;
int v;
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter the value for the radius:");
double radius = keyboard.nextDouble();
d = 2*radius;
a = 4*Math.PI*Math.pow(radius, 2)) ;
v = 4/3*Math.PI*Math.pow(radius, 3) ;
System.out.println("The diameter of the sphere is: "+ d);
System.out.println("TThe surface area of the sphere is: "+ a);
System.out.println( "The volume of the sphere is: "+ v);
}
} However, it doesn't work and keeps saying this:
Circle.java:15: error: incompatible types: possible lossy conversion from double to int
d = 2 * radius;
^
Circle.java:16: error: incompatible types: possible lossy conversion from double to int
a = 4 * Math.PI * (radius*radius) ;
^
Circle.java:17: error: incompatible types: possible lossy conversion from double to int
v = 4/3 * Math.PI * (radius*radius*radius) ;
Can someone help please and explain the error that I have made? Any help is appreciated. Thank you!!!!!