Question
Lab_02.2B For the following exercises, use return methods with parameters. Create a new.repl doc called APLab_02.2B, and the following files. Exercise_01: Rectangle Create a new
Lab_02.2B For the following exercises, use return methods with parameters. Create a new.repl doc called APLab_02.2B, and the following files.
Exercise_01: Rectangle
Create a new file called Rectangle.java, and add the following.
maino
Declare 2 variables - length, and width for the length and width of your rectangle, and set their values to user inputs. Print the perimeter, which is returned from
calcPerim calcPerim
Take 2 parameters that accept the local length and width values from main(. Calculate and return the perimeter.
Exercise_02: Average
Create a new file called Average.java, and add the following.
main
Declare 3 variables - numi, num2, and num3, and set their values to user inputs. Print the average, which is returned from
calcAvgo. calcAvg
Take 3 parameters that accept the values from num1, num2, and num3 that are local to main(). Calculate and return the average.
Exercise_03: Cube
Create a new file called Cube.java, and add the following.
main
Declare a variable side for the length of the sides of your cube. Set the value of side to a user input. Print the surface area of a cube, with a length of side. Print the surface area of your cube which is returned from
calcSurf| calcSurfa
Take 1 parameter, which will accept the value of your local variable for side length from main(). Calculate and return the surface area.
Exercise 04: Circle
Create a new file called Circle.java, and add the following.
Main
Declare a variabler for the radius of your circle, and set the value ofr to a user input. Print the area of your circle, which is returned from
calcAreal calcAreal
Take 1 parameter, which will accept the value of your local variable for radius from main. Calculate and return the area of your circle.
********You can use 3.14 for P ********
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