Cmis 102 Hw 4 Essay

1160 Words5 Pages
Homework Assignment 4 Charles Black CMIS102-4015 Professor Dale Goode 27Sep15 Problem definition: Write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user. A. Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section. In this problem, we have to calculate and display the area and perimeter for set of input values, entered by user. We will take input from user for length and width. And then calculate the area and perimeter for rectangle for the numbers input. Desired Output: The desired output is area and perimeter of rectangle. Required Input: The required input consists of the length and width of the rectangle. The program asks user to input length and width of rectangle. Calculations: Variables used: length: (float) to store value of length of rectangle entered by user width: (float) to store value of width of rectangle entered by user Area: (float) to store area of rectangle Perimeter: (float) to store perimeter of rectangle Formula for Calculating Area of Rectangle Area = length * width Formula for Calculating Perimeter of Rectangle Perimeter = 2 *( length + width ) Sample Calculation Suppose we have following user input: Length =4.0 Width=8.0 Subprogram Calculate_Area (length,width,Area) Calculate_Area (4.0,8.0 ) Area = length * width = 4 * 8 = 32 Subprogram Calculate_Perimeter (length,width, Perimeter) Calculate_ Perimeter (4.0,8.0 ) Perimeter = 2 *( length + width ) = 2 *( 4 + 8 ) = 24 B. Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment

More about Cmis 102 Hw 4 Essay

Open Document