Program which reads the length and width of a rectangle and displays its area and perimeter.

import java.io.*;
class ractangle
{   public static void main(String[] asd)throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int length, width, peri;
String num;
System.out.println("Enter the length and width of rectangle(press enter after each number)::");
num=in.readLine();
length=Integer.parseInt(num);
num=in.readLine();
width=Integer.parseInt(num);
System.out.println("Area"+length*width);
System.out.println("Perimeter"+ 2*(length+width));

}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s