Thursday 13 June 2013

program in java to calculate area of rectangle

import java.io.*;
class simple_program_area_rectangle
{
    public static void main(String args[])
    {
        int a,b,h;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter the value for breath");
            b=Integer.parseInt(cin.readLine());
            System.out.println("Enter the value for hieght");
            h=Integer.parseInt(cin.readLine());
            a=b*h;
            System.out.println("the area of rectangle = "+a);
        }
        catch(Exception e)
        {
            System.out.println("wrong data");
        }
    }
}

No comments: