area calculations with data types
area calculations with data types
/** * ARUN MAVURAM */ public class floatingpoint { static double width = 10.01333332d; static float height = 4.12345678999999f; public static void main(String[] args) { System.out.println("width:" +width); System.out.println("height:" +height); // compute area of square // System.out.println("area of rectangle is :" +(width*height)); System.out.println("-----------------------------------"); // compute area of triangle // double base = 7.0111d; double height = 2.00d; System.out.println("base:" +base); System.out.println("height:" +height); System.out.println("area of triangle is:" +(base*height/2)); System.out.println("------------------------------------"); //compute area of trapezium// int a = 20; int b = 30; int h = 2; System.out.println("area of parallel side1:" +a); System.out.println("area of parallel side2:" +b); System.out.println("distance between parallel sides:" +h); System.out.println("area of trapezium is :" +(h*(a+b/2))); System.out.println("-----------------------------------"); // compute area of rhombus // short x = 125; short y = 127; System.out.println("length of the first diogonal:" +x); System.out.println("length of the second diagonal:" +y); System.out.println("area of rhombus is :" +(x*y/2)); } } /* output width:10.01333332 height:4.123457 area of rectangle is :41.2895489206472 ----------------------------------- base:7.0111 height:2.0 area of triangle is:7.0111 ------------------------------------ area of parallel side1:20 area of parallel side2:30 distance between parallel sides:2 area of trapezium is :70 ----------------------------------- length of the first diogonal:125 length of the second diagonal:127 area of rhombus is :7937 */
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/