Why is it saying incompatible types ?
When the house variable is an int type, the double variable isn't showing any decimal values. Like if the house variable is 3 and an int type and if I do "double A = 100 / house; it is showing 33.0 but the decimal values are not showing, it should be 33.3333.... something with decimal values. When I change the house variable to a double type, its working fine but now I can't divide house with 100, for example if I do - int D = 100 / house; - its showing incompatible types as house is now a double type variable, I need both answer where double A = 100 / house; will have decimals and int D = 100 / house; will not have decimals... the code - class MyClass { public static void main(String[] args) { int houses = 3; double B = 100 / houses; System.out.println(B); int C = 100 / houses; System.out.println(C); } } Any solutions guys ?