Error recieved when compiling - AreaCalculationProgram.java:23: error: incompatible types: possible lossy conversion from double to int -


so, here code. calculates area of circle.

import java.util.*; public class areacalculationprogram { public static void main(string [] args)

    {        //code circle        int radius, areaofcircle, area;      scanner sc = new scanner(system.in);      system.out.print("enter diameter of circle");      double diameter = sc.nextdouble();      integer intdiameter = sc.nextint();      diameter = intdiameter.doublevalue();      areaofcircle = (int) math.pow((diameter/2),2 ) * math.pi;      system.out.print("areaofcircle" + area); 

shown below error get:

areacalculationprogram.java:23: error: incompatible types: possible lossy conversion double int     areaofcircle = math.pow((diameter/2),2 ) * math.pi;                                               ^ 

why areaofcircle int? problem requirement? should use round/floor/ceil math class methods (depends)


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -