Free Essay

Homework3

In:

Submitted By ohthatbillie
Words 470
Pages 2
CMIS 102 6382

September 28, 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 + width* width)
Display “The Diagonal Length is :”, diagoanlLength
End Function

Flowchart

Program Explanation

The Program is for finding the Area and Perimeter of a rectangle with the values required for the calculation getting from the user as length and width

This is a modular design, the main program includes the function calls and functions defined as sub programs

Here The main program contains three functions GetInput(), CalcArea(), CalcPerimeter() , CalcDiagonalLength()

The variables length, width, area, perimeter and diagoanlLength are declared as double.

GetInput() function accepting the values of length and width from the user

The function CalcArea() calculates the Area of a rectangle as the “ length * width” and displays the value of the Area

The function CalcPerimeter() defines the perimeter of a rectangle as “(length + width) * 2”
And displays the perimeter value as the result

The last function CalcDiagonalLength() defines the diagonal length of a rectangle as sqrt( length*length + width* width)” And displays the diagonal length value as the result

Test Data

|Test Data 1 | |
|Enter Length : 10 |The area is : 120 |
|Enter Width : 12 |The Perimeter is : 44 |
| |The diagonal length is : 15 |
|Test Data 2 | |
|Enter Length : 20 |The area is : 200 |
|Enter Width : 10 |The Perimeter is : 60 |
| |The diagonal length is : 22 |
|Test Data 3 | |
|Enter Length : 15 |The area is : 180 |
|Enter Width : 12 |The Perimeter is : 54 |
| |The diagonal length is : 19 |

-----------------------
RETURN

Accept length, width

Display “Enter the length and width “

GetInput() ()

CalcPerimeter()

CalcArea()

GetInput()

Integer length, width, area, perimeter

START

area= length * width

CalcArea()

Display “The Perimeter is :”, perimeter

RETURN

CalcPerimeter()

perimeter = (length + width) * 2

Display “The Area is :”,area

CalcDiagonalLength()

STOP

RETURN

CalcDiagonalLength()

diagoanlLength = sqrt( length*length + width* width)

Display “The diagonal length is :”, diagoanlLength

RETURN

Similar Documents

Free Essay

Homework3

...Homework #: 3: Due: November 20, 2015 You are given the following information. S=50, X=50, simple annual risk-free interest rate is 5%, standard deviation of monthly stock returns is 10%. [Caution: must covert to annualized continuous compounding values] 1. What is the value of a one-year European call option using the Black-Scholes option pricing model? Show values of N(d1) and N(d2) using Excel and using the formula provided in the lecture note. rc = ln (1+rs) = 0.04879 = 4.879% d1 = [ln 50/50 + 4.879%*1 + (10%2*1)/2] / (10%*√1) = [0 + 4.879% + 0.005] / 0.1 = 0.05379/0.1 = 0.5379 N(d1) = 0.70467695 d2 = 0.5379 – 10%*√1 = 0.5379 – 0.1 = 0.4379 N(d2) = 0.66927061 e-rcT = e-0.04879*1 = 0.952381 C0 = 50*0.70467695 – 50*0.952381*0.66927061 = 35.2338475 – 31.8700306 = 3.3638 2. Solve the value of the above one-year American call using CBOE Options Toolbox [pic] 3. Noting the Greek values: How will the call value change for a. 1% change in interest rate [pic] b. $1 increases in the stock price [pic] c. Reduction of one-day in maturity [pic] 4. All options are European and the stock does not pay a dividend. Which option is relatively more expensive? Explain. (Hint: Compute implied volatility). a. S = $50, C (X=$60) =$14 [pic] b. S = $50, C (X=$65) =$10 [pic] Option (a) is relatively more expensive because the...

Words: 257 - Pages: 2

Premium Essay

Econ Hw3

...1) Total Revenue | $120,000 | | Salary Forgone | $50,000 | | Employee’s wages | 40,000 | | Loss on Rent | $10,000 | per year | Material Cost | 15,000 | | Lost return on savings (5%) | $ 1,000 | per year | Rental of Equipment | 5,000 | | Savings invested in business | $20,000 | | a) | | | | | | | Economic Costs | $121,000 | | | | | Accounting Costs | 60,000 | | | | | b) | | | | | | | Accounting Profit | $60,000 | | | | | C) | | | | | | | Economic Profit | ($1,000) | | | | | d) | | | | | | | No, because she is forgoing the rent income she would have been earning before she started her own business | | 2)   | Fixed Cost | Marginal Cost | Variable Costs | | | Small Plant | $10,000 | $2.00 | $12,000 | | | | Medium Plant | $15,000 | $1.40 | $12,600 | | | | Large Plant | $25,000 | $0.50 | $9,000 | | | | a) | | | | | | | Average Cost of Production | | | | Clock Radios | 6000 | 9000 | 18000 | | | | Small Plant | $3.67 | $3.11 | $2.56 | | | | Medium Plant | $3.90 | $3.07 | $2.23 | | | | Large Plant | $4.67 | $3.28 | $1.89 | | | | b) | | | | | | | 6000 Units - Small Plant | | | | | | | 9000 Units - Medium Plant | | | | | | | 18000 Unit - Large Plant | | | | | | | c) | | | | | | | In the short run the average total cost of producing 18000 units at $2.23 a unit in a medium plant is $40,140...

Words: 1166 - Pages: 5