Question: Length and breadth of a rectangle are 5 and 7 respectively. Write a program to calculate the area and perimeter of the rectangle.
Ans:
package CoreJava;
import java.util.Scanner;
import java.util.Random;
public class javaCore {
public static void main(String[] args) {
int l = 5;
int b = 7;
int a = (l*b);
//this will area of a rectangle is given
System.out.println("This is area of a rectangle:" + a);
int p = 2*(l + b);
System.out.println("This is perimeter of the rectangle" + p);
}
}
----------------------------------------------------------------------------------------------------------
Question:
Comments
Post a Comment