Design a program to perform the following task: Calculate the usable area in square feet of a house. Assume that the house has a maximum of four rooms, and that each room is rectangular.
I. Problem Analysis
1.) To find the usable area in square feet of a house, what is the necessary input needed to solve the problem?
-Each room needs to be declared so that the program will know where each measurement belongs. Room#1 will be WidthFeet1 and LengthFeet1.
-Use the command of “input” which will allow the user to input the values the program will need to calculate.
-Use the command of “write” to let the user know what value is needed, i.e., Write “What is the length of room one in feet?” To ask the user “What is the length of room one in feet?” Use that statement and function for each room. 2.) To find the usable area in square feet of a house, what are the necessary outputs needed to solve the problem?
-Use the “write” command to give the user information about the data collected and computed. Example: Write “The usable square footage of the house is:” + TotalSquarefeet
-I want to display to the user the areas of each room and total usable space.
-I will use “+TotalSquarefeet” to show the user the value of the data
3.) To find the total usable living space in square feet of a house, what are the steps needed to solve the problem?
-In order to solve this problem, I need to know how to calculate the area of a rectangle. This formula is square feet= length*width
-To find the total area of the house I need to know how to add all of the areas of each room to get the total usable area.
-Use “Set” to allow the program to set the equations. Example: Set Room1=Widthfeet1*Lengthfeet1
Input Variables are WidthFeet1, WidthFeet2, WidthFeet3, WidthFeet4, LengthFeet1, LengthFeet2, LengthFeet3, and LengthFeet4 all of which are integers.
Output Variable is TotalSquareFeet, which will also be an integer.
*Each variable represents each room and it’s width and length.
II. Program Design and Documentation
There are three fundamental tasks that need to happen in order for the program to give the correct result.
1. The user must input the corresponding width and length of each room into the designated spot. 2. The program will calculate the area by multiplying the length times the width to obtain the area of each room and add the values together to get the usable square footage. 3. The output results will be displayed to the user in square feet.
Pseudocode
Write “Please enter the length and width of each room in feet.”
Input LengthFeet1
Input WidthFeet1
Input LengthFeet2
Input WidthFeet2
Input LengthFeet3
Input WidthFeet3
Input LengthFeet4
Input WidthFeet4
Set TotalSquareFeet= (LengthFeet1*WidthFeet1) + (LengthFeet2*WidthFeet2) + (LengthFeet3*WidthFeet3) + (LengthFeet4*WidthFeet4)
Main Module Declare all variables As Integers
Write “Square Footage Calculator”
Write “Please enter the length and width of each room in feet.”
Call Input Data Module
Call Perform Calculations Module
Call Output Results Module
End Program
Input Data Module Write “What is the length of room 1?” Input LengthFeet1 Write ”What is the width of room 1?” Input WidthFeet1 Write “What is the length of room 2?” Input LengthFeet2 Write “What is the width of room 2?” Input WidthFeet2 Write “What is the length of room 3?” Input LengthFeet3 Write “What is the width of room 3?” Input WidthFeet3 Write “What is the Length of room 4?” Input LengthFeet4 Write “What is the width of room 4?” Input WidthFeet4
Perfom Calculations Module Declare TotalSquareFeet as Int
Set TotalSquareFeet= (LengthFeet1*WidthFeet1) + (LengthFeet2*WidthFeet2) + (LengthFeet3*WidthFeet3) + (LengthFeet4*WidthFeet4)
Output Results Module Wrtie “Your house is” + TotalSquareFeet + “SqFt”
// Declare the variables
Declare LengthFeet1 as Int
Declare WidthFeet1 as Int
Declare LengthFeet2 as Int
Declare WidthFeet2 as Int
Declare LengthFeet3 as Int
Declare WidthFeet3 as Int
Declare LengthFeet4 as Int
Declare WidthFeet4 as Int
// Get the length and width in feet of each room
Write “ What is the length and width in feet of each room?”
Input LengthFeet1
Input WidthFeet1
Input LengthFeet2
Input WidthFeet2
Input LengthFeet3
Input WidthFeet3
Input LengthFeet4
Input WidthFeet4
// Calculate the area of each room and add values together for square footage
Set TotalSquareFeet= (LengthFeet1*WidthFeet1) + (LengthFeet2*WidthFeet2) + (LengthFeet3*WidthFeet3) + (LengthFeet4*WidthFeet4)
// Output the result
Wrtie “Your house is” + TotalSquareFeet + “SqFt”
III. Test Data
Input: Room length and width (in feet) | Expected output: Total square footage of house (in square feet) | Room1: length=36, width=51;Room 2: length=45, width=50;Room 3: length=40, width=53;Room 4: length=42, width=52 | 8390 Sqft. |