1) Write the Java program to calculate the area of the rectangle having lenght (l) = 8 and breadth (b) = 4.
- class Maths
- {
- public static void main(String [] args)
- {
- int l=8;
- int b=4;
- int area=l*b
- System.out.print(area);
- }
- }
Output:
32
----------------------------------------------------xxx---------------------------------------------------------------
2) Write the Java program to calculate the perimeter of the rectangle having lenght (l) = 8 and breadth (b) = 4.
- class Maths
- {
- public static void main(String [] args)
- {
- int l=8;
- int b=4;
- int a=2;
- int peri= a(l+b);
- System.out.print(peri);
- }
- }
Output:
24
----------------------------------------------------xxx---------------------------------------------------------------
3) Write the Java program to calculate the area and perimeter of the square having lenght(l)=4.
- class Maths
- {
- public static void main(String [] args)
- {
- int l=4;
- int area= l*l;
- System.out.print(area);
- }
- }
Output:
16
----------------------------------------------------xxx---------------------------------------------------------------
4) Write the Java program to calculate the area and perimeter of the square having lenght(l)=4.
- class Maths
- {
- public static void main(String [] args)
- {
- int l=4;
- int a=4;
- int peri= l*a;
- System.out.print(peri);
- }
- }
Output:
16
----------------------------------------------------xxx---------------------------------------------------------------
0 Comments