









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Software Engineering Steps:
Top-down Design
Case Study Example:
Given the length in meters of a roll of wire, find the length in feet.
We know one meter is 39.37 inches.
Requirements Specification Wire is purchased in rolls measured in meters, but customers need length in feet.
Analysis Program Input: wire length in meters (variable WMETER)
Problem Output : wire length in feet (variable WFEET)
Additional Program Variable : wire length in inches (variable WINCHS)
Relevant Formulas or Relations 1 meter = 39.37 inches 1 foot is 12 inches
Design
Refine step 2 2.1 Convert wire length from meters to inches. 2.2 Convert wire length from inches to feet.
PROGRAM statement
Comments
Declarations
Rules of FORTRAN identifiers
Implicit Data Typing of Identifiers:
Identifiers cannot be keywords PROGRAM, REAL, INTEGER, PRINT, STOP
The PRINT Statement:
The READ Statement:
Assignment Statement:
The STOP statement:
The END statement:
Operator operation Example:
Consider: A + B * C - D / (-E) (A + B + C) / D + (A - C + (-A * B) )
Expression Evaluation Order: Order Operator Association 1 Parenthesized subexpressions 2 ** Right to Left 3 * and / Left to Right 4 + and - Left to Right
Expression rules:
FUNCTION REFERENCE OPERATION
ARGUMENT TYPE
RESULT TYPE INT (arg) Converts arg to an integer by dropping the fractional part
REAL INTEGER
NINT (arg) Rounds arg to nearest integer
REAL INTEGER
REAL (arg) Converts arg to a real value
INTEGER INTEGER
ABS (arg) Finds absolute value of arg
REAL REAL
IABS (arg) Finds absolute value of arg
INTEGER INTEGER
SQRT (arg) Computes square root of arg ( arg >0.0)
REAL REAL
EXP (arg) (^) Computes earg REAL REAL ALOG (arg) Computes natural logarithm, ln( arg ) ( arg >0.0)
REAL REAL
ALOG10 (arg) Computes logarithm, log(arg) (arg>0.0)
REAL REAL
SIN (arg) Computes sine of angle arg in radians
REAL REAL
COS (arg) Computes cosine of angle arg in radians
REAL REAL
TAN (arg) Computes tangent of angle arg in radians
REAL REAL
MOD (a1,a2) Computes remainder of a1/a
INTEGER INTEGER
MAXO (a1,... ,an)
Selects largest value from list a1,... ,an
INTEGER INTEGER
AMAX1 (a1,... ,an)
Selects largest value from list a1,... ,an
REAL REAL
MINO (a1,... ,an)
Selects smallest value from list a1,... ,an
INTEGER INTEGER
AMIN1 (a1,... ,an)
Selects smallest value from list a1,... , an
REAL REAL
Finding the value of a coin collection of nickels and pennies.
Requirements Specification Given a count of pennies and nickels, calculate the among of money.
Analysis Program Input: Count of nickels (INTEGER NICKEL) Count of pennies (INTEGER PENNIES)
Problem Output : Number of dollars, number of cents (loose change)
(INTEGER DOLLAR) (INTEGER CHANGE)
Additional Program Variable : Total value in cents (INTEGER TOTVAL)
Relevant Formulas or Relations one dollar = 100 pennies one nickel = 10 5 pennies
Design
Implementation:
PROGRAM COINS C Determines the value of a coin collection.
C Declarations REAL PENNYS, NICKEL, DOLLAR, CHANGE, TOTVAL
C Read in the count of nickels and pennies. PRINT *, 'Enter number of nickels' READ *, NICKEL PRINT *, 'Enter number of pennies' READ *, PENNYS
C Compute the total value in cents. TOTVAL = 5 * NICKEL + PENNYS
C Find the value in dollars and change. DOLLAR = TOTVAL / 100 CHANGE = MOD(TOTVAL, 100)
C Display the value in dollars and change. PRINT *, 'Your collection is worth ', DOLLAR, ' 1dollars' PRINT *, ' and ', CHANGE, ' cents.' STOP END
Bug: An error in a computer program is referred to as a "bug". Removing errors from a program is called "debugging".
Syntax Errors: These are errors discovered by the compiler as it attempts to translate the program into machine language. These are caused by improper use of the FORTRAN syntax (grammar) rules.
Run-Time Errors: Run-time, or execution, errors are discovered while the program is running and attempts to perform an illegal operation (divide by zero, entering improper data, etc.).
Common Errors: