Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions