public class Main {
public static void main(String[] args) {
int length = 5;
int breadth = 7;
int area = length * breadth;
int perimeter = 2 * (length + breadth);
System.out.println("The area is : " + area);
System.out.println("The perimeter is : " + perimeter);
}
}
NOTE:
- Didn't need Scanner because there was no need to take input from the user.
- Used int because there was no decimal in input.
- To calculate area and perimeter we need length and breadth which is provided to us as input.
- Used int to calculate as we didn't need decimal point in our output for now.
No comments:
Post a Comment