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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started