how to read an integer of DOUBLE datatype with type casting
please, tell me how to read an integer of DOUBLE data type using
1-readInt() with tpe casting.
2-any other approach
Code java:
ublic static void main(String [] args)
{
Scanner read = new Scanner(System.in);
double radius;
Circle []c1 =new Circle[5];
for (int i=0;i<c1.length;i++)
{
System.out.println("radius("+(i+1)+")= ");
radius=read.nextInt();
c1[i] = double new Circle2(radius);
System.out.print("obj("+(i+1)+").Area= "+c1[i].area());
System.out.print("obj("+(i+1)+").Area= "+c1[i].circum());
System.out.print("obj("+(i+1)+").Area= "+c1[i].diam());
}
Re: how to read an integer of DOUBLE datatype with type casting
c1[i] = new Circle2((double)radius);
However, Circle2 isn't defined anywhere.
Second, why not make radius a double to start with by
radius = readIn.nextDouble();
?
Re: how to read an integer of DOUBLE datatype with type casting
Perhaps you meant
c1[i] = new Circle(radius);
If there is a class called Circle2,
try type casting it
cl[i] = (Circle) new Circle2(radius);
Re: how to read an integer of DOUBLE datatype with type casting
Quote:
Originally Posted by
javapenguin
Perhaps you meant
c1[i] = new Circle(radius);
If there is a class called Circle2,
try type casting it
cl[i] = (Circle) new Circle2(radius);
Primmmmaaaa
thank you