Question: Creating an Area and Perimeter Function in Java : your goal is to ask the user for the length of on side of a square,
Creating an Area and Perimeter Function in Java : your goal is to ask the user for the length of on side of a square, invoke a functional method called calculateArea that returns the area of the square, invoke a functional method called calculatePerimeter that returns the perimeter of the square, and show the results in a message box.
Main method: Ask the user via a JOptionPane box for length of on side of a square and parse and save that response into a double variable. Call the area method and save the result in a variable. Call the perimeter method and save the result in a variable Display the area and perimeter results in a JOptionPane message box
calculateArea Functional Method: Take in the length of the side of the square that the user typed Return the area of the square using the following equation: lengthOfSide * lengthOfSide
calculate Perimeter Functional Method : lengthOfSide *4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
