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 prognim: Create a program to calculate the area and circumference of a rectangle using the following functions: main: Function that is cuecuted fint to start the program o Create two variables length and width used for input of float numbers (see ostput below) - Crcate variable strOperation used for inprut to ask user whether to calculate area (a) or circurnference (c) (rec output below) a Print a welcome message (iee output below) - Call function fOperatios (see below) passing strOperatioe and length and width o Print out result (sec output below) IOperation(pOperation, pliength, pWidth): o Test parameter pOperation whether it is "a a4 or " " - Call either function fCalcArea(plength, PW idth) or fCaleCircumference(plength, p Wid th) - Populate strOutput with cither the string "The area of the rectasele = - of "The circumference of the rectangle -" and the resalt of the eperation (cither area or circumference) Retuen stroutput ECaleAra(plength, pWidth) Perform the calculation of the area (width * leagth) and renim the resalt fCalcCircumference(plengh, pWidth) Perfoem the calsulation of the circumference (2 * (aidth + lenghh) and return the result Citurnfercnce
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
