Free Essay

Area and Perimeter

In:

Submitted By Conri
Words 290
Pages 2
When starting this program I had to look at how people would insert the information. Typically, you would assume that a person would input the length and width for a rectangle asa positive whole number, but this isn’t always the case. To deal with these cases, I had to implement two different features. The first feature to deal with none whole numbers is to make all of the numbers as floats. These variables are therefore float length, float width, float area, float perimeter.After making the numbers floats, a user can input any number even if it has a decimal. The second was to input a while loop after each user input for length and width in order to deal with the possibility of a negative number. A rectangle cannot have a negative or zero side so the while loop deals with this by asking the user to another number for length or width. After this has been completed it is necessary to send both of the numbers to the functions. To find the area, you take the length and width and multiply them together which gives you the area or Area = Length * Width. An example of this is below:
Area = Length * Width
User Input: Length = 2 & Width = 4
Area = 2 * 4
Area = 8
To find the Perimeter of a rectangle however, it is a bit different. To find the Perimeter you have to use the following formula P = 2(Length) + 2(Width). You use this formula due to the fact that you have 2 sides which are measured for the length and 2 sides which are measured for the width. An example of this is below:
Perimeter = 2(Length) + 2(Width)
Perimeter = 2(2) + 2(4)
Perimeter = 4 + 8

Similar Documents

Free Essay

Write a Program, Using Functions, That Calculates the Area and Perimeter of a Rectangle Whose Dimensions (Length and Width) Are Provided by a User

...rectangular has length 4m for each side and width 3m for each side. Now, the program will be written by using functions that calculates the area and perimeter of a rectangular. Analysis: For the space problem, we need to output the area of the following variables: + Name of the area is calculated, GetArea (as string) + The length of rectangular, LenRec (as float) + The width of rectangular, WidRec (as float) + The total length of rectangle, Total2L (as float) + The total width of rectangle, Total2W (as float) + The perimeter of rectangle. PerRec (as string) The necessary input to the program: + In order to output the rectangle’s area (GetArea), the program must know what it is, so the string Area must be input by the user. + To compute the usable area of rectangular, the program must know how many sides in the rectangle. We have LenRec and WidRec are float variable and are also input data. + To compute the rectangle’s perimeter (PerRec), the program must know what it is, so the string perimeter must be input by the user. Obtaining the Necessary Formulas: The rectangular has length 25m and width 18m. So we have GetArea = 4m x 3m = 12m Generalize these computations by using variables instead of numbers: therefor, the suggestion formula for calculating the area and perimeter of rectangular is: GetArea = LenRec x WidRec GetArea is neither an input nor output variable, but it used solely in processing...

Words: 676 - Pages: 3

Free Essay

Cmis 102 Hw 4

...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 *(...

Words: 1160 - Pages: 5

Free Essay

Homework3

...2014 A. Problem Analysis • The purpose of the program is to calculate the area ,perimeter and diagonal length of a rectangle with dimensions (Length and width) are provided by a user. • Input the values of length and width from the user • For finding the area, the calculation is length * width • For the perimeter, calculation is (length + width) * 2 . • For finding the diagonal length , the formula is sqrt( length*length + width* width) B. Program Design Input/Output The program will prompt user to input: • Legth • Width Calculate the area • Area= length * width • Display the area Calculate the perimeter • Perimeter =( length + width) * 2 . • Display the perimeter Calculate the diagonal length • diagoanllength = sqrt( length*length + width* width) • Display the diagonal length Pseudo Code Start Declare the variables length, width, area, perimeter, diagoanlLength as double GetInput() CalcArea() CalcPerimeter() CalcDiagonalLength() Stop Function GetInput() Display “Enter the length and width “ Accept length, width End Function Function CalcArea() area= length * width Display “The Area is :”,area End Function Function CalcPerimeter() perimeter = (length + width) * 2 Display “The Perimeter is :”, perimeter End Function Function CalcDiagonalLength() diagoanlLength = sqrt( length*length +...

Words: 470 - Pages: 2

Free Essay

Homework

...Analysis: This program will calculate the area or perimeter of a rectangle whose dimensions are provided by the user. I will use integer variables, float variables, selection statements, a loop, and functions in this program. “Option” and “Start” will be declared as integers, the float variables will be “length”, “width”, and “answer”. To find the area of a rectangle, I will use the equation area=length*width. To find the perimeter of a rectangle, I will use the equation perimeter=2(length+width). Pseudocode: BEGIN // This program will calculate the area or perimeter of a rectangle whose dimensions are provided by the user. SET area and perimeter functions //Declare Variables DECLARE Option, Start as integer DECLARE length, width, answer as float WHILE Start >0 //Ask for user input WRITE “Enter a positive number to calculate the area or perimeter.” WRITE "To end this program enter 0 or a negative number.” INPUT Start IF Start>0 WRITE "Enter 1 to calculate area or 2 to calculate the perimeter.” INPUT Option IF Option==1 WRITE "Please enter the length of the rectangle:" INPUT length WRITE "Please enter the width of the rectangle:" INPUT width SET answer=area(length,width) WRITE "The area of the rectangle is %.2f. " ELSE IF Option==2 WRITE "Please enter the length of the rectangle:" INPUT length WRITE "Please enter the width of the rectangle:” INPUT width WRITE "The perimeter of the rectangle is %.0f.” END...

Words: 486 - Pages: 2

Free Essay

Heyhey

...namespace std; Int main () { Float a; //a=Length Float b; //b=width Float area, perimeter; cout <<”This program computes for the area of a Rectangle and perimeter”; <<endl; cout <<”Enter Length: “; cin >>a; cout <<”Enter Width: “; cin>>b; area=a*b; perimeter=2*(a+b) cout <<”Area: ”<<area<<endl; cout <<”Perimeter: ”<<perimeter<<endl; return 0; } //PTASK6 #include <iostream> using namespace std; int main () { float length, width; float acm, ain, aft, amtr; //acm=area cm, ain= area inch, aft=area feet, amtr= area meter float pcm, pin, pft, pm; //pcm=perimeter cm, pin=perimeter in, pft=perimeter feet, //pm= perimeter meter cout<<"Input Length of the Square in cm:"; cin>>le ngth; cout<<"Input Width of the Square in cm:"; cin>>width; //AREA FORMULA acm=length*width; ain=acm*2.54; aft=ain*12; am=aft*3.28; //cout area cout<<"Area of a Square:"<<endl; cout<<acm<<"sq.cm"<<endl; cout<<ain<<"sq.in"<<endl; cout<<aft<<"sq.ft"<<endl; cout<<am<<"sq.m"<<endl<<endl; //PERIMETER pcm=2*(length+width); pin=pcm*2.54; pft=pin*12; pm=pft*3.28; //cout perimeter cout<<"Perimeter of a Square:"<<endl; cout<<pcm; cout <<"sq.cm"<<endl; cout<<pin; cout<<"sq...

Words: 320 - Pages: 2

Premium Essay

Risk Assessment Checklist

...Risk Assessment Site Security Survey Checklist Worksheets Risk Assessment Checklist This checklist is a guide for Risk Assessment Teams. It is also a tool to assist in familiarizing clients with risk assessment concepts and processes. It should be noted, that each client’s facility or enterprise surveyed would be different. So at some point individual surveys through the site survey and interview process will take on a form of their own. Remember the interview and review process is designed to assist all the risk and client Assessment Team members to maximize their understanding of the clients needs. Risk Assessment and Prevention Goals • To have the client identify all key facility assets and develop a comprehensive Asset Protection Plan developed by using the rings of protection concept. • To have the client perform a hazardous materials evaluation and develop a comprehensive Hazardous Materials Plan. • To have the client perform a Process Hazard Analysis and develop a comprehensive Critical Point Protection Plan and process. • To have the client perform a consequence assessment of personnel policies and processes. • To have the client perform a physical factors assessment and develop Physical Factors Plan. • To have the client perform a mitigation assessment and to develop a comprehensive Mitigation Process Plan. • To have the client perform a security assessment analysis and to develop a comprehensive...

Words: 3641 - Pages: 15

Free Essay

Sec 320

...Perimeter Security Applications Robinson Paulino DeVry College of New York Sec- 330 Professor: Gerard Beatty Perimeter Security Applications Outline Introduction 2 Intruder Detection Accuracy 3 Security Cameras 4 1. Using Size Filters for Video Analytics Accuracy 4 2. Geo-Registration and Perimeter Security Detection Accuracy 5 3. Clarity against a moving background 5 Perimeter Security Best Practices 6 Auto Tracking PTZ Camera 6 Long Range Thermal Camera 6 Covering Perimeter Camera Blind Spots 7 Determine a Perimeter Camera’s Range 7 Perimeter Fence . 8 Chain-Link Fences Protection 8 Electric and Infrared Fences 8 Fiber Optic Intrusion Detection Systems 9 In-Ground Intrusion Detection Systems 10 References 11 Perimeter Security Applications Introduction Physical security is the protection offered for property, these may be buildings or any other form of asset, against intruders (Arata, 2006). . The idea therefore, is to keep off unwanted persons or objects from ones premises. One’s premise is defined by a boundary which separates private property from the rest of the land. This boundary is referred to as the perimeter. The perimeter could be physical or logical. Physical security is intended to keep intruders from land and grounds around such property. Logical perimeters on the other hand, are for protection against computer sabotage or any other remote malicious activities (Fennelly, 2012). In a nutshell, perimeter security...

Words: 2429 - Pages: 10

Free Essay

River Characteristics

...characteristics such as cross profile, wetted perimeter, hydraulic radius, roughness and efficiency change downstream. Describe and explain how channel characteristics change downstream. The channels characteristics such as the cross profile, wetted perimeter, hydraulic radius, roughness and efficiency, change along the course of the river. The rivers width is a lot wider downstream than it is upstream and is also a lot deeper which would be shown in the cross profile of the river. The cross profile of a river is a slice through the river this then shows exactly how wide and deep the river is and how rough the river bed is depending on if there is boulders or dips. Upstream it is narrow and shallow and further downstream this begins to change to being wide and deep due to the energy from the water causing lateral and vertical erosion. This then has an immediate effect on the wetted perimeter, length of a river channel in contact with the water at a cross section, as the wider and deeper the river channel the more surface area in contact with the water therefore resulting in a larger wetted perimeter. Further upstream nearer the source of the river the wetted perimeter is likely to be small as there is less surface in contact with the water as it is shallow and narrow whereas in the lower course closer to the mouth of the river the wetted perimeter should be a larger number as the river bed and banks will be larger therefore more surface area in contact with the water. The relationship...

Words: 539 - Pages: 3

Free Essay

Umuc-Cmis 102 Hw 4

...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...

Words: 339 - Pages: 2

Free Essay

Pseudocode - Using Functions to Solve Dimensions of Rectangle

...program will calculate the area and perimeter using different functions. //The numerical values for length and width will be provided as an input by the user //Set function areaofrec as float //Set function periofrec as float //START Program //set menuSelect, intValue as int //set length, width, and result as float //set while loop (while intValue >0) continue loop //print “Enter a positive integer to calculate the area or perimeter of a rectangle; “ //print “OR a negative integer to exit program” //input positive or negative integer //create if else statement //If intValue >0 continue with program //else if intValue < 0 exit program //if intValue > 0 print “Enter 1 to calculate area, 2 to calculate perimeter” //input menuSelect option //if menuSelect == 1 //call the area function //print “you chose to calculate the area of the rectangle!” //print “please enter the length and width of the rectangle” //print “enter length first, hit enter, enter width, hit enter” //input length and width //set result = areaofrec(length,width) //print result “The area of the rectangle is (result) “ //else if menuSelect == 2 //call the perimeter function //print “you chose to calculate the perimeter of the rectangle!” //print “please enter the length and width of the rectangle” //print “enter length first, hit enter, enter width, hit enter” //input length and width //set result = periofrec(length,width) //print result “The perimeter of the rectangle is (result)...

Words: 280 - Pages: 2

Premium Essay

Physical Security Operations

...use of physical security consists if a series if actions that are used to protect someone against unwanted or illegal invasion. There are three levels of physical security which are the security practitioner should be concerned with. They are the outer perimeter, inner perimeter, and the interior. OUTER PERIMETER Your actual property line defines the outer perimeter. In controlling the outer you must control who can drive/walk onto your property. You can use barbed wire fence, a guard shack. You need to weigh the risk of an intruder entering your property and the cost of the available physical security measure. There are two concepts involved in perimeter security, which is Natural Access Control and Territorial Reinforcement. Natural Access Control is the use of building and landscaping features to guide the people as they and enter/exit a space. You all also want to discourage intruders to close any and all potential exits. potential (1) Clearly defined entrances the first thing to the access control is the approach to your area. That is can a car drive onto your property without it being notice? If this does happen that means you need to consider of using curbs, barriers, gates to direct the traffic to a single control area. A guard shack would be a good deterrent to any intruder. Now there is the foot traffic to consider now. Can an unauthorized person walk into your building without being noticed? There should be at least one entrance to the building and the foot traffic...

Words: 717 - Pages: 3

Free Essay

Vpn vs Ids

...today’s society security is of paramount importance, whether it’s your business, home, vehicle, or computer. Companies are responsible for securing their employees, work area and the technology they use to operate their business. On a daily basis companies are under attack making them vulnerable to more and more worms, viruses, denial of service (DoS) attacks and hacking, shutting them down for various periods of times. With the advance technology more and more companies are storing information digitally. Having unsecure networks are leading to enormous amount of private information being public. The networks should protect data and maintain confidentiality, integrity and availability of the network. Companies should implement intrusion detection systems (IDS) because hackers are smarter and their intrusions are getting harder to trace. Intrusion Detection System An intrusion detection system or IDS is a system that attempts to identify intrusions, which can be defined to be unauthorized uses, misuses, or abuses of the computer systems by either authorized users or external perpetrators [1]. The in the past the major ways that intrusion detection systems were described were host based IDS (HIDS) and network based IDS (NIDS). An addition to the IDS family is perimeter intrusion detection systems (PIDS). A perimeter intrusion detection system will be installed within the isolation zone to detect the presence of individuals or vehicles [3]. In parallel to rigorous investigation into...

Words: 1372 - Pages: 6

Premium Essay

Write a Program, Using Functions, That Calculates the Area and Permieter of a Rectangle Whose Dimensions (Length and Width) Are Provided by a User

...using functions, that calculates the area and perimeter of a rectangle whose dimensions (Length and width) are provided by a user. Assume the rooms are rectangular and that the user can enter from 1 to 10 rooms for the house. Also calculate and display the total area and total perimeter (i.e. the sum of the perimeters) of the house. Note: this is very similar to Assignment 1 and you can reuse any code there that is appropriate. Before attempting this exercise, be sure you have completed all of chapter 8 and course module readings, participated in the weekly conferences, and thoroughly understand the examples throughout the chapter.   There are 4 main components of your submission including the problem analysis, program design and documentation, and sample test data.1. Provide your analysis for the following problem statement: You need to write a program that calculates the area and perimeter of a rectangle whose dimensions (Length and width) are provided by a user.Your analysis should be clearly written and demonstrate your thought process and steps used to analyze the problem. Be sure to include what is the required output? What is the necessary input and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe any necessary formulas and sample calculations.2. Provide your program design for the problem you analyzed for calculating and displaying the area and perimeter of a rectangle.  Always work for modular...

Words: 471 - Pages: 2

Premium Essay

Appendix B Cjs 250

...outer perimeter. Video surveillance is active on the north fence and inactive on the south. A manned guard station permits entrance into the outer perimeter from the west; an unmanned and unlocked gate permits entrance from the east. No Trespassing signs are posted at intervals upon the perimeter fence; Employees only is posted on the gate. Visitors must obtain a pass at the guard station. The outer perimeter contains the parking lot and office building. The perimeter has two light posts that, when functioning, illuminate the entire parking lot. Currently, the light post on the south side is not functioning. The office building exterior has three outer doors and one window. The first door is marked with an Employees Only sign and requires a badge for access. The second door is the main entrance for visitors and is manned by a guard, who requires a visitor’s pass for admittance. The third door is an emergency exit only and is clearly marked. Any attempt to gain access through the first door without a badge, the second door without a pass, or the third door at all, results in alarm activation and guard response. The window is locked from within; any attempt to gain access through the window also activates the alarm and alerts the guard. The interior of the office building is segmented into two major areas. The first area is the employee workstation; only employees can access this area. Visitor and employees can access the second area. Both the first and second areas are monitored...

Words: 666 - Pages: 3

Premium Essay

Perimeter Security

...another building onto the lot that is directly to the east is going to be under construction soon. A construction site always poses a number of challenges to make sure that the perimeter is secured. A challenge to this is that it is a construction site so the perimeter is not permanent. The very first thing that needs to be done to make sure that the perimeter is secured is to make sure that there is a fence up around the construction site. The fence will only be put up around the new lot and not around the old lot. The fence will serve multiple purposes while it is up. The first purpose will be for somewhat of a basic access control access into the construction area. If the fence was put up around both of the areas then it would be harder to control some of the access. Along with access control it will also help with safety issues that could possibly come up from people wondering into the construction area. To help prevent people from scaling the fence three lines of common barbed wire will set on top. The main purpose of the fence will be to help with making sure that people do not try to enter the area and steal building materials, tools, or just vandalize the property. There will need to be a gate that is a part of the fence to make sure that vehicles and personal are able to get into the area when needed. This gate will be secured by lock and key to ensure. The key will only be given to people that are need of having it such as the construction supervisor and also...

Words: 1456 - Pages: 6