Question: Create the following program: *Create a program to calculate the area and circumference of a rectangle using the following functions: *main: o Function that is
Create the following program:
*Create a program to calculate the area and circumference of a rectangle using the following functions:
*main:
o Function that is executed first to start the program
o Create two variables length and width used for input of float numbers (see output below)
o Create variable strOperation used for input to ask user whether to calculate area (a) or circumference (c) (see output below)
o Print a welcome message (see output below)
o Call function fOperation (see below) passing strOperation and length and width
o Print out result (see output below)
fOperation(pOperation, pLength, pWidth):
o Test parameter pOperation whether it is a or c
*Call either function fCalcArea(pLength, pWidth) or fCalcCircumference(pLength, pWidth)
o Populate strOutput with either the string The area of the rectangle = or The circumference of the rectangle = and the result of the operation (either area or circumference)
o Return strOutput
fCalcArea(pLength, pWidth):
o Perform the calculation of the area (width * length) and return the result
fCalcCircumference(pLength, pWidth) o Perform the calculation of the circumference (2 * (width + length) and return the result
Area: Circumference:
Create the following program: Create a program to calculate the area and circumference of a rectangle using the following functions: main: Function that is executed first to start the program Create two variables length and width used for ingut of float numbers (see output below) Create variable strOperation used for input to ask user whether to calculate area (a) or circumference (c) (sec outpur below) Print a weleome message (see output below) Call function fOperation (see below) passing strOperation and length and width Print out result (see output below) Eoperation(pOperation, plength, pWidth): Test parameter pOperation whether it is " a " or " c - Call cither function fCalcArea(plength, pW idth) or fCaleCircumaference(pLength, pWidth) Populate strOutput with either the string "The area of the reetangle = " or "The circumference of the fectasgle =" and the result of the operation (either area or circumfereace) Retarn stuOutput fCaleArea(plength, pWidth) o Perform the calculation of the area (width * length) and return the result ECalcCircumference(pLength, pWidth) o Perform the calealation of the circumference (2 (width + length) and retum the result Atsa: Circumference: Upload the following files to Canvas
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
