Computer Essay

374 WordsJul 23, 20122 Pages
CMIS102 Homework Assignment 4 (Worth 16% of your grade) Student Name: William Moss Class/Section: CMIS Professor Name: Countryman Assignment due date: 16 JUL 12 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 – - Main module: This module will be the main starting module. It is responsible to get user input and call other modules to calculate and display rectangle area and perimeter. - calcArea module: This module will take rectangle length and width as input and return rectangle area as output. Area will be calculated as: Area = length x width - calcPerimeter module: This module will take rectangle length and width as input and return rectangle perimeter as output. The parameter will be calculated as: Perimeter = 2 x width + 2 x length - displayResults module: This module will take Area and Perimeter of the triangle as input arguments and display results to the user. B. Program Design – At program startup, main module will be executed which will carry out the following steps: o Declare variables. o Get user input for length and width. o Call calcArea module to calculate area of the rectangle. o Call calcPerimeter module to calculate perimeter of the rectangle. o Call dispResults module to display results to the user. Psuedocode: Module Main() Declare width, height, area, perimeter as float Display “Enter rectangle height: “ Input height Display “Enter rectangle width: “ Input width area = calcArea(width, height) perimeter = calcPerimeter( width, height) dispResults(area, perimeter) End Main Module calcArea(width,

More about Computer Essay

Open Document