-
Language
Java using BufferedReader
-
Description
It calculates tha area and the perimeter of a rectangle getting the height and the width.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.*;
public class AreaAndThePerimeterOfARectangle {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double area, height, perimeter, width;
System.out.print("Enter the value of height: ");
height = Double.parseDouble(in.readLine());
System.out.print("Enter the value of width: ");
width = Double.parseDouble(in.readLine());
area=height*width;
perimeter=height*2+width*2;
System.out.println("Value of area: " + area);
System.out.println("Value of perimeter: " + perimeter);
in.close();
}
}
public class AreaAndThePerimeterOfARectangle {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double area, height, perimeter, width;
System.out.print("Enter the value of height: ");
height = Double.parseDouble(in.readLine());
System.out.print("Enter the value of width: ");
width = Double.parseDouble(in.readLine());
area=height*width;
perimeter=height*2+width*2;
System.out.println("Value of area: " + area);
System.out.println("Value of perimeter: " + perimeter);
in.close();
}
}