In this homework, you will design a program to perform the following task: Desig
ID: 3759651 • Letter: I
Question
In this homework, you will design a program to perform the following task:
Design and write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.
There are 5 components of your submission including:
Program Description- A detailed, clear description of the program you are building.
Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about how your design will allow any number of students and final grades to be possible inputs.
Test plan - Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)
Flowchart
Pseudocode- Provide pseudocode of your overall design that fulfills the requirements of the project
Show any input validation logic in pseudocode and also reflect that in flow-chart.
All of these components can be placed in a single word document. You will copy and paste your flow-chart in Microsoft Word document. That single word document should be uploaded.
Example application test data:
Test Case #
Input
Expected Output
1
Length =4.0, Width=8.0
Area = 32
Perimeter = 24
2
Your input data
Your expected output
3
Your input data
Your expected output
Test Case #
Input
Expected Output
1
Length =4.0, Width=8.0
Area = 32
Perimeter = 24
2
Your input data
Your expected output
3
Your input data
Your expected output
Explanation / Answer
#include <stdio.h>
float areaofrec( float length, float width);
float periofrec(float length, float width);
int main ()
{
int menuSelect, intValue;
float length, width;
float result = 0;
while (intValue > 0)
{
printf ("Enter positive Integer to calculate the area/perimeter; ");
printf ("OR a negative Integer to exit the program.: ");
scanf(" %d", &intValue);
if (intValue > 0)
{
printf ("Enter 1 to calculate area, 2 to Calculate the perimeter: ");
scanf(" %d", &menuSelect);
if (menuSelect == 1)
{
printf("You select to calculate the area of the rectangle! ");
printf(" Please enter the length of the rectangle: ");
scanf(" %f ", &length);
printf(" Please enter the width of the rectangle: ");
scanf(" %f", &width);
result = areaofrec(length, width);
printf("The area of the rectangle is %.0f ", &result);
}
else if (menuSelect == 2)
{
printf("You chose to calculate the perimeter of the rectangle! ");
printf(" Please enter the length of the rectangle");
scanf(" %f ", &length);
printf(" Please enter the width of the rectangle:");
scanf(" %f", &width);
result = periofrec(length, width);
printf("The area of the rectangle is %.0f ", &result);
}
else
printf("Invalid menu item, only 1 or 2 is accepted ");
}
}
return 0;
}
float areaofrec( float length,float width)
{
return length*width;
}
float periofrec( float length, float width)
{
return (length*2)+(width*2);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.