Answer to Question #251575 in Java | JSP | JSF for AYESHA

Question #251575

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


1
Expert's answer
2021-10-16T11:02:46-0400
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;	
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS