Calculate the float value
Previous | Home | Next |
Following Program for calculate the float value(using Loop).
/* * Save as a FloatValue.java * Program for float the value(using Loop) */ package r4r.co.in; public class FloatValue { public static void main(String[] args) { /* * Loop Start form 1.0 to the limit 2.0, and adding 0.2 in every cycle * PI= 3.14, value already define in java.lang.Math class. */ for (double radius = 1.0; radius <= 2.0; radius += 0.2) { System.out.println("radius of Circle = " + radius + ", and area of circle = " + Math.PI * (radius * radius)); } } }
radius of Circle = 1.0, and area of circle = 3.141592653589793
radius of Circle = 1.2, and area of circle = 4.523893421169302
radius of Circle = 1.4, and area of circle = 6.157521601035993
radius of Circle = 1.5999999999999999, and area of circle = 8.04247719318987
radius of Circle = 1.7999999999999998, and area of circle = 10.178760197630927
radius of Circle = 1.9999999999999998, and area of circle = 12.566370614359169
Previous | Home | Next |