Write a Java program that calculates area and perimeter of square in a function. Name Calculate Area and Calculate Perimeter respectively. Pass the values to the function from main () while calling functions
public class Main {
public static void main(String[] args) {
System.out.println(calculateArea(2, 4));
System.out.println(calculatePerimeter(3, 6));
}
static int calculateArea(int a, int b) {
return a * b;
}
static int calculatePerimeter(int a, int b) {
return 2 * a + 2 * b;
}
}
Comments
Leave a comment