Free Essay

Umuc-Cmis 102 Hw 4

In:

Submitted By Rhombus
Words 339
Pages 2
Joe Metz
Professor James Huskins
CMIS 102 6385
February 22nd 2015

Program Description – This program will calculate the area and perimeter of a rectangle with the provided user input.

Analysis – First the user needs to provide the values for both the length and the width of the rectangle they want to determine the area and perimeter from. From there calculations need to be made. For this example we will use a rectangle with the length of 3 and a width of 9. The formula for determining the perimeter of a rectangle is P=2(l+w) where l and w stand for length and width and P is perimeter. While the formula for determining the area of a rectangle is A=lw. Where A is area and l and w are length and width. By using the values stated previously we can plug in the numbers for that formula and get 2(3+9). Simplified that's 2x12=24. To determine the area we can plug the numbers in and get A=3x9 or A=27. By writing the formulas into a function and calling that function we can have the program use any variety of input by the user to determine what the area and perimeter of a rectangle is with any values.

Test Case - Test Case # | Input | Expected Output | 1 | length(l) = 3, width(w) = 9 | Perimeter (P) =24 Area (A) =27 | 2 | l = 5, w = 10 | P =30 A= 50 | 3 | l = 9, w = 36 | P=90 A= 324 |

Pseudocode -

//Declare Variables
L, W, P, A
//Float Variables
P, A
Write “Please Enter the Length of the Rectangle”
Input Length of the Rectangle
Write “Please Enter the Width of the Rectangle”
Input Width of the Rectangle
//Call A and P Function
Print “The Area of a Rectangle the Length of “L” and the Width of “W” is “A”
Print “The Perimeter of a Rectangle with the Length of “L” and the Width of “W” is “P”

//A and P Function
A=lw
P=2(l+w)

Similar Documents