Free Essay

# Square Footage

In:

Submitted By RLUNDY1
Words 1559
Pages 7
Pseudocode: An Introduction
Flowcharts were the first design tool to be widely used, but unfortunately they do not very well reflect some of the concepts of structured programming. Pseudocode, on the other hand, is a newer tool and has features that make it more reflective of the structured concepts. Unfortunately, the narrative presentation is not as easy to understand and follow.

RULES FOR PSEUDOCODE 1. Write only one stmt per line
Each stmt in your pseudocode should express just one action for the computer. If the task list is properly drawn, then in most cases each task will correspond to one line of pseudocode. EX: TASK LIST: Read name, hourly rate, hours worked, deduction rate Perform calculations gross = hourlyRate * hoursWorked deduction = grossPay * deductionRate net pay = grossPay – deduction Write name, gross, deduction, net pay PSEUDOCODE: READ name, hourlyRate, hoursWorked, deductionRate grossPay = hourlyRate * hoursWorked deduction = grossPay * deductionRate netPay = grossPay – deduction WRITE name, grossPay, deduction, netPay

2.

Capitalize initial keyword
In the example above, READ and WRITE are in caps. There are just a few keywords we will use: READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL

3.

Indent to show hierarchy
We will use a particular indentation pattern in each of the design structures: SEQUENCE: keep statements that are “stacked” in sequence all starting in the same column. SELECTION: indent the statements that fall inside the selection structure, but not the keywords that form the selection

LOOPING: indent the statements that fall inside the loop, but not the keywords that form the loop EX: In the example above, employees whose grossPay is less than 100 do not have any deduction. TASK LIST: Read name, hourly rate, hours worked, deduction rate Compute gross, deduction, net pay Is gross >= 100? YES: calculate deduction NO: no deduction Write name, gross, deduction, net pay PSEUDOCODE: READ name, hourlyRate, hoursWorked grossPay = hourlyRate * hoursWorked IF grossPay >= 100 deduction = grossPay * deductionRate ELSE deduction = 0 ENDIF netPay = grossPay – deduction WRITE name, grossPay, deduction, netPay

4.

End multiline structures
See how the IF/ELSE/ENDIF is constructed above. The ENDIF (or END whatever) always is in line with the IF (or whatever starts the structure).

5.

Keep stmts language independent
Resist the urge to write in whatever language you are most comfortable with. In the long run, you will save time! There may be special features available in the language you plan to eventually write the program in; if you are SURE it will be written in that language, then you can use the features. If not, then avoid using the special features.

SELECTION STRUCTURE
We looked at this in Chap 2: yes amount < 1000

no

interestRate = .06

interestRate = .10

The pseudocode for this would be: IF amount < 1000 interestRate = .06 ELSE interestRate = .10 ENDIF // the “yes” or “true” action // the “no” or “false” action

Some selections are of the “do it or don’t” (one sided) variety. For example:

The pseudocode for this is: yes average < 60 ?

IF average < 60 DO SendWarning ENDIF

DO SendWarning

no

It is considered poor form to have a 1-sided IF stmt where the action is on the “no” or ELSE side. Consider this code: IF average < 60 NULL ELSE DO GivePassingGrade ENDIF This could (and should) be rewritten to eliminate the NULL “yes” part. To do that, we change the < to its opposite: >= as follows: IF average >= 60 DO GivePassingGrade ENDIF

NESTING IF STATEMENTS
What if we wanted to put a little menu up on the screen: 1. Solitaire 2. Doom 3. Monopoly and have the user select which game to play. How would we activate the correct game? READ gameNumber IF gameNumber = 1 DO Solitaire ELSE IF gameNumber = 2 DO Doom ELSE DO Monopoly ENDIF ENDIF

yes

no

DO Solitaire DO Doom

no

DO Monopoly

We must pay particular attention to where the IFs end. The nested IF must be completely contained in either the IF or the ELSE part of the containing IF. Watch for and line up the matching ENDIF.

LOOPING STRUCTURES
One of the most confusing things for students first seeing a flowchart is telling the loops apart from the selections. This is because both use the diamond shape as their control symbol. In pseudocode this confusion is eliminated. To mark our loops we will use these pairs: WHILE / ENDWHILE REPEAT / UNTIL START Count = 0 The loop shown here (from the last chapter) will have the following pseudocode: count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The end” no Count < 10 yes Add 1 to count

Write “The end”

Notice that the connector and test at the top of the loop in the flowchart become the WHILE stmt in pseudocode. The end of the loop is marked by ENDWHILE. What statement do we execute when the loop is over? The one that follows the ENDWHILE.

STOP Write count

Sometimes it is desirable to put the steps that are inside the loop into a separate module. Then the pseudocode might be this: Mainline count = 0 WHILE count < 10 DO Process ENDWHILE WRITE “The end” Process ADD 1 to count WRITE count We often use this name for the first module. Initialization comes first The processing loop uses this module Termination does clean-up Go thru these steps and then return to the module that sent you here (Mainline)

START Count = 0

This time we will see how to write pseudocode for an UNTIL loop: count = 0 REPEAT ADD 1 to count WRITE count UNTIL count >= 10 WRITE “The end” Notice how the connector at the top of the loop corresponds to the REPEAT keyword, while the test at the bottom corresponds the the UNTIL stmt. When the loop is over, control goes to the stmt following the UNTIL.

Write count

no

Count >= 10 yes Write “The end”

STOP

Pseudocode Disadvantages  It’s not visual  There is no accepted standard, so it varies widely from company to company Pseudocode Advantages  Can be done easily on a word processor  Easily modified  Implements structured concepts well Flowchart Disadvantages  Hard to modify  Need special software (not so much now!)  Structured design elements not all implemented Flowchart Advantages  Standardized: all pretty much agree on the symbols and their meaning  Visual (but this does bring some limitations)

HOW WE STORE AND ACCESS DATA
What happens when we execute READ stmt? READ name, hoursWorked, hourlyRate, deductionRate The computer stores all program data into memory locations. It knows these location by their addresses. It is perfectly able to understand code like: READ 19087, 80976, 10943, 80764 but we would have a hard time with it. So we name our storage locations using words that are descriptive to us. Every language has its own (different) set of rules about how these names are formed. We will use a simple style:      variable names will start with a lowercase letter they will have no spaces in them additional words in them will start with a capital names must be unique within the program consistent use of names

The READ statement tells the computer to get a value from the input device (keyboard, file, …) and store it in the names memory location. When we need to compute a value in a program (like grossPay) we will use what is called an assignment stmt. variable = expression Be careful to understand the difference between these two stmts: num1 = num2 num2 = num1

The WRITE stmt is used to display information on the output device (screen, printer). To display words, enclose them in quotes. A variable’s value will be displayed. So if the variable name currently contains John Smith, then the stmt WRITE “Employee name: “, name will output like this: Employee name: John Smith

CALCULATION SYMBOLS
We will often have to represent an expression like the one that computes grossPay. To symbolize the arithmetic operators we use these symbols grouping ( ) exponent ** or ^ multiply * divide / add + subtract There is a precedence or hierarchy implied in these symbols.

ORDER OF EXECUTION
( ) ** / * + equations in parenthesis exponentiation division and multiplication addition and subtraction

Please Excuse My Dear Aunt Sally

Note: when operators of equal value are to be executed, the order of execution is left to right. Examples: AREA = R2 SUM = A2 + B2 PERIM = 2(L + W) A A C BC B

A C B

A BC

D 2  C B

D BC

2

value = 100*2/5-3 = 200/5-3 = 40-3 = 37 value = 100*2/(5-3) = 100*2/2 = 200/2 = 100 value = 100*((2/5)-3) = 100*(.4-3) = 100*-2.6 = -260

SELECTION
When we have to make a choice between actions, we almost always base that choice on a test. The test uses phrases like “is less than” or “is equal to”. There is a universally accepted set of symbols used to represent these phrases:

> < >= < =

=

LOGICAL OPERATORS: AND, OR, NOT
AND: if any of the conditions are false, the whole expression is false. ex: IF day = “Saturday” AND weather = “sunny” WRITE “Let’s go to the beach!” ENDIF

OR: if any of the conditions are true, the whole expression is true ex: IF month = “June” OR month = “July” OR month = “August” WRITE “Yahoo! Summer vacation!” ENDIF

NOT: reverses the outcome of the expression; true becomes false, false becomes true. ex: IF day “Saturday” AND day “Sunday” WRITE “Yuk, another work day” ENDIF

### Similar Documents

Free Essay

#### Calculate Square Footage

...Assignment due date: 04/01/2012 Problem definition: Calculate the usable area in square feet of house. Assume that the house has a maximum of four rooms, and that each room is rectangular. A. Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section. In this program the overall goal is to obtain the usable area in square feet in a house. The results or overall goal would be considered the required output. To obtain the required output we would need the necessary input. The necessary information regarding the house is that it contains a maximum of four rooms that are rectangular in shape. I will obtain the required output from the given input by multiplying length x width to find the number of square feet in each rectangular room. Once the combined square footage of each room is determined this will give me the amount of usable living space. We would need to know each room length and width, then calculate each rooms area and then find the sum of all four rooms. Area of Room 1= Length1 x Width1 Area of Room 2= Length2 x Width2 Area of Room 3= Length3 x Width3 Area of Room 4= Length4 x Width4 Area of Room 1 + Room 2 + Room 3 =Room 4 = Total Square footage B. Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment your pseudocode. Useable square footage of a house Rooms- Total number of Rooms = 4 Area-Area=L x W of each room ...

Words: 643 - Pages: 3

Free Essay

#### House Square Footage Calculator

...this program is to calculate the square footage of a house with up to 3 rooms. The program will ask the user to enter the width and length of each room in feet. The expected output will multiplying the length and width of each room and then summing the square footage of each room to yield the total square footage of the house. Program name: House Square Footage calculator Analysis: We will use sequential statements All variables will be float We will define these variables: Total_SqFt Room_1_L Room_2_L Room_3_L Room_1_W Room_2_W Room_3_W Input: The user will be prompted to enter the room dimension for each room individually (up to three rooms) “Enter Length and Width of room 1” “Enter Length and Width of room 2” “Enter Length and Width of room 3” Ouput: The output will be defined as the total square footage of the house and will use the input provided by the user to calculate output with this formula: The Square footage of the house will be calculated by this formula: SqFt = (Room_1_L x Room_1_W) + (Room_2_L + Room_2_W) + (Room_3_L x Room_3_W) The output message will display a message “Total Square foot of the house is: SqFt” Test Plan Three test cases will be done Test Case # | Input | Expected Output | 1 | Room1: length=10, width=14; Room 2: length=9, width=10; Room 3: length=12, width=12; | 374 square feet | 2 | Room1: length=5, width=9; Room 2: length=15, width=20; Room 3: length=6, width=12; | 417 square feet | | | 3 | Room1: length=8...

Words: 850 - Pages: 4

#### Cost Accounting

...bills with a three-month maturity. (T-Bill) Consumer Price Index (CPI): a standard measure of consumer price inflation. Risk-free rate: the rate of return on a riskless investment. (debt that is virtually free of any default) Risk premium: the extra return on a risky asset over the risk-free rate; the reward for bearing risk. (excess return) Variance: a common measure of volatility. (squared difference between the actual returns and the average return—the bigger the number the more the actual returns tend to differ from the average return. Standard deviation: square root of the variance Pg. 19 Calculating the Historical Standard Deviation: 1. Calculate the average. 2. Find the difference between each given point and the average. 3. The difference is how much each term deviates from the average. Calculating the Historical Variance: 1. Repeat steps 1-3 2. Square each of the variances 3. Add all the squared terms 4. Divide the sum by the number of returns 1 less Normal Distribution: a symmetric, bell-shaped frequency distribution that is completely defined by its average and standard deviation. (bell curve) Geometric average return: the average compound return earned per year over a multiyear period. Answers the question: “What was your average compound return per year over a particular period?” Tells you what you actually earned per...

Words: 415 - Pages: 2

#### Square Pharma

...(Safety and Health) for a particular job post with the help of supervisor and HR manager of any company. We have chosen Square Pharmaceutical Ltd and the job post on which we have prepared our report is Medical Promotion Officer. We visited Square Pharmaceuticals Limited. There we appointed with Mr. Younus Ali (Sr. Manager, HRD) and Mr. Tamim Ahsan( Territory officer in Dhaka region). They were very cordial and helpful to us share their experience and provide the required information as they can provide within the policy. We asked them different relevant questions and information to provide. 1.1. Profile of Square Pharmaceuticals Ltd. Corporate Headquarters | : SQUARE CENTRE 48, Mohakhali Commercial Area Dhaka 1212, Bangladesh | Factory | : Shalgaria, PabnaTown, Pabna | Established | :1958 | Constitution | : Public Ltd Company | Founder Chairman | : Mr. Samson H Chowdhury | Chairman | : Mr. Samuel S Chowdhury | Managing Director | : Mr. Tapan Chowdhury | Details of Business | : 1. Pharmaceuticals Products 2. Bulk Chemicals 3. AgroVet Products | Manufacturing Units | :1. Pharmaceuticals Division 2. Agro Vet Division 3. Chemical Division | 1.2. Human Resource Department of Square Pharmaceutical Ltd SQUARE, with its progressive business outlook, believes and practices corporate work culture with a classic blend of efficiency and equity. SQUARE believes in company growth by increasing efficiency level of employees and for that offering excellent environment and...

Words: 2745 - Pages: 11

Free Essay

#### Cmis 102 Assignment 2

...Program Description: The program I’m creating is going to be utilized to determine the usable surface area of each room in a four-room house and then calculate the usable square footage of the house as a whole. Analysis: To start this program, I needed to come up with a plan or blueprint. I utilized the Modular Approach to break this down into smaller parts. The main module is the solution to the problem; determine the square footage of a four-bedroom house with the all rooms being rectangles. The program will perform the equation for the area of a rectangle (Area = Length * Width) for each room. Each sub-module will perform the equation and come up with a solution. Once the solutions are identified for each room, we must finish the task by finding the sum of the four rooms’ square footage to calculate the houses’ total square footage (Area RM1 + Area RM2 + Area RM3 + Area RM4 = Total Square Footage of House). Calculate the Total Square Footage of a four-bedroom house. Calculate the Total Square Footage of a four-bedroom house. Area of Room One Area of Room One PLUS PLUS Area of Room Two Area of Room Two PLUS PLUS Area of Room Three Area of Room Three PLUS PLUS Area of Room Four Area of Room Four Analysis (CONT): In this program, I will be using various variables with different definitions. The table below will list and identify the variables: VARIABLES | DEFINITION | LR1 | LENGTH OF ROOM ONE | WR1 | WIDTH...

Words: 843 - Pages: 4

Free Essay

#### Maths

...have to attempt only one lf the alternatives in all such questions. * Use of calculator is not permitted. * An additional 15 minutes time has been allotted to read this question paper only. SECTION – A 1. Any point on the line x + y = 0 is of form a. b. c. d. (,−) 2. The coefficient of y in the equation 3(2x – y) + x + 2y = 5 is b. 7 b. – 5 c. – 1 d. 1 3. If in a sphere, volume and surface area are numerically equal, then radius will be: c. 1 b. 3 c. 2 d. 4 4. The length of longest pole that can be put in a room of dimensions (10m x 10m x 5m) is d. 15m b. 16m c. 10m d. 12m 5. If in a quadrilateral, diagonals are equal, then it cannot be a : e. Square c. Rhombus f. Parallelogram d. Rectangle 6. The median of a triangle divide it into two g. Triangles of equal area c. Right triangles h. Equilateral triangles d. Isosceles triangles. 7. A fair die is thrown. The probability that a prime number will occur is i. b. c. d....

Words: 725 - Pages: 3

Free Essay

#### Assignment1

...area in square feet of a house. Assume that the house has a maximum of four rooms, and that each room is rectangular. Program Description The purpose of this program is to calculate the usable area (square feet) of a four room house. Analysis To calculate the usable area in square feet in the house I would first need to identify the inputs and outputs. I know the house has a maximum of 4 rooms that are rectangular in shape, this is my input. Using the area formula (L x W) I can determine the square feet for each room. Adding the square feet for each room will provide the amount of usable area in square feet of the house and my output for this program. Test Plan Test Case # | Input | Expected Output | Results | 1 | Room 1: length = 16, width = 14Room 2 length = 13, width = 13Room 3: length = 10, width = 11 | 503 square feet | Pass | 2 | Room 1: length = 12, width = 16Room 2 length = 11, width = 14Room 3: length = 10, width = 11 | 456 square feet | Pass | 3 | Room 1: length = 12, width = 12Room 2 length = 12, width = 11Room 3: length = 11, width = 10 | 386 square feet | Pass | Pseudocode //This program will calculate the usable area in square feet of a four room house //Declare WidthRoom1, LengthRoom1 As Float // Declare WidthRoom2, LengthRoom2 As Float //Declare WidthRoom3, LengthRoom3 As Float //Declare WidthRoom4, LengthRoom4 As Float //Declare TotalHouseSquareFeet As Float Write “This program will help you calculate the usable area in square feet...

Words: 273 - Pages: 2

Words: 433 - Pages: 2

Free Essay

#### Java Class Shape

...Shape class /** * This is a class that represent any shape. This is the superclass of all shapes. * @author yklam2 * */ public class Shape { private boolean canvas[][]; private int width; private int height; /** * Create an empty shape. */ public Shape() { this(0, 0); } /** * Create a shape with a specific `width` and `height`. * @param width The `width` of this shape. * @param height The `height` of this shape. */ protected Shape(int width, int height) { this.width = width; this.height = height; canvas = new boolean[height][width]; } /** * Set a pixel * @param row The `row` of the pixel. * @param column The `column` of the pixel. */ protected void setPixel(int row, int column) { if(row >=0 && row < height && column >=0 && column < width) canvas[row][column] = true; } /** * Clear a pixel * @param row The `row` of the pixel. * @param column The `column` of the pixel. */ protected void clearPixel(int row, int column) { if(row >=0 && row < height && column >=0 && column < width) canvas[row][column] = false; } /** * Get the area of this shape. Area is the number of pixel set in this * @return The area. */ public int getArea() { int area = 0; shape. for(boolean [] row: canvas) for(boolean pixel: row) if(pixel) ++area; } return area; /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { String drawing = ""; for(boolean [] row: canvas) { if(drawing.length() > 0) //...

Words: 704 - Pages: 3

Free Essay

#### Math

...1. The diagram shows a trapezium. The lengths of three of the sides of the trapezium are x – 5, x + 2 and x + 6. All measurements are given in centimeters. The area of the trapezium is 36 cm2. a. Show that x2 – x – 56 = 0 Trapezium Area = ½ (Sum of parallel sides) high 36 = ½ (x+2+x+6) (x-5) 36 = ½ (2x+8) (x-5) …………….. Multiply by 2 72= (2x+8) (x-5) ………………... Expand 72= 2x2-10x+8x-40 2x2-2x-112= 0……………..……... Divide by 2 x2-x-56= 0 b. Find the length of the shortest side of the trapezium. x2-x-56=0 ………………..……... factorize (x-8) (x+7) = 0 Either x-8 = 0 OR x+7 = 0 x = 8 accept x = -7 Reject x-5 is the shortest side and it equals to (8-5=3 cm) 2. The diagram shows a 6-sided shape. All the corners are right angles. All the measurements are given in centimeters. The area of the shape is 85 cm2. Hence, work out the length of the shortest side of the 6-sided shape. Area of rectangular 1= 3x (2x-7) = 6x2-21x Area of rectangular 1= x (3x+4) = 3x2+4x Area of shape = area of rectangular 1 + area of rectangular 2 85 = 6x2-21x + 3x2+4x 9x2-17x-85 = 0 ………………….. Solve using the formula x= 4.159 accept x= -2.27 reject 3. We are going to fence in a rectangular field and we know that for some reason we want the field to have an enclosed area of 75 ft2. We also know that we want the width of the field to be 3...

Words: 640 - Pages: 3

Free Essay

#### Become a Web Developer

...Project Objectives! Our aim is to design and develop a simple site design with a modern layout that's conducive to CMS systems like WordPress. We won't be applying any wild and crazy style effects in our design (the point here is to keep it simple), but we are going to approach the entire process, from start to finish, as a study in layout and a proper use of margins and padding. We'll be using the 960 grid system from start to finish, so if you've ever wondered what it's like to use the system, now's a great time to learn! We'll be making a few deviations from the norm, but for the most part we'll be using 960gs in the design and coding phases. Once you guys/gals are done, you're welcome to customize the design all you want with your own fonts, colors, styles and textures! Remember, this is just a starting out point - you're welcome to go as nuts as you want when it comes to the personality of your own version of the design. A Brief Course Outline. We might break this up differently once we hit the coding phase, but this should give you a good idea of where we're heading with this series: • The Design Phase • Session 1: Laying The Groundwork and Designing the Homepage • Session 2: Designing the Support Pages (Available Next Week) • The Coding Phase • Session 3: Slicing and XTHML Coding (Available Soon) • Session 4: Convert To a Wordpress Theme (Available Soon) Resources Used For This Project You can use your own resources if you'd like, but here's the full list of...

Words: 2814 - Pages: 12

Free Essay

#### Module 6

...Multiple Choice 1 through 10 starting on page 267 1) B 2) D 3) A 4) C 5) B 6) B 7) C 8) B 9) A 10) A Algorithm Workbench 1 through 3 problems on page 269 1) Declare integer rand set rand = random (1, 100) Display rand End function 2) Display “Enter a number” Input number Set number = number /2 Display “The half of”, number, “is” Display “Press Enter to continue” ...

Words: 256 - Pages: 2

Free Essay

#### Perimeter of Figures

... Example: What is the area of this triangle? Height = h = 12 Base = b = 20 Area = ½ × b × h = ½ × 20 × 12 = 120 Volume of Rectangular Figures   The volume of a rectangular prism is the length on the side times the width times the height. Example: What is the volume of the rectangular prism with the dimension shown below? Use the formula for the volume of a cylinder as shown below. Volume= (2) (5) (3) = 30 Area of Irregular Figures Without symmetry, even shape, formal arrangement It may seem easy to find the area of a rectangle, but what if the figure has more than 4 sides? . The area of the first rectangle is 72 square centimeters and the area of the second rectangle is 50 square centimeters. Together there are 72 + 50 = 122 square centimeters. Therefore, the area of the entire figure is 122 square centimeters. Surface Area of Rectangular Figures Surface area is the sum of the areas of all the surfaces of a 3 – Dimensional figure. 7 m 7 m 1 m 1 m 12m 12m S.A. = 2(1 x 7 + 12 x 7 + 12 x 1) S.A. = 2 (7 + 84 + 12) S.A. = 2 (103) S.A. = 206 Determining if two ratios are proportion If the product of the means equals the product of the extremes, then the two ratios form a true proportion. In less methyl way, cross multiply and if you get the same number both times, it is a true proportion. The top number of one ratio times the bottom number of the other. Example 5 x 18 = 90 10 x 8 = 80 not proportion. For 8/24...

Words: 876 - Pages: 4

#### Transformation

... | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. (a) Diagram 1.1 shows points P and Q drawn on a Cartesian plane. Transformation T is the translation . Transformation R is a clockwise rotation of about the centre Q. State the coordinates of the image of point P under each of the following transformations: (i) T2 (ii) TR [4 marks] (b) Diagram 1.2 shows two hexagons, EFGHJK and PQREST drawn on square grids. | | | | | | | | | | | P Q R S T E F G H J K Diagram 1.2 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (i) PQREST is the image of EFGHJK under the combined transformation WV. Describe in full, the transformation: (a) V (b) W (ii) It is given that EFGHJK represents a region of area 36 cm2 . Calculate the area, in cm2, of the region represented by the shaded region. [8 marks] Answers 1 (a) (i) (3,5) (1,8) (ii) (0.1) ( (b)(i) (a) Reflection in the...

Words: 582 - Pages: 3