100% found this document useful (63 votes)
592 views

Software Testing A Craftsman S Approach 4th Jorgensen Solution Manual

This document provides examples of problems that can be represented using pseudocode, including the Triangle Problem, NextDate function, Commission Problem, Simple ATM system, Currency Converter, Windshield Wiper Controller, and Garage Door Controller. Pseudocode is a language-neutral way to describe algorithms and processes using a natural language style that can then be translated to an actual programming language. The examples range from simple mathematical and date functions to more complex systems with graphical user interfaces.

Uploaded by

Keith Lee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (63 votes)
592 views

Software Testing A Craftsman S Approach 4th Jorgensen Solution Manual

This document provides examples of problems that can be represented using pseudocode, including the Triangle Problem, NextDate function, Commission Problem, Simple ATM system, Currency Converter, Windshield Wiper Controller, and Garage Door Controller. Pseudocode is a language-neutral way to describe algorithms and processes using a natural language style that can then be translated to an actual programming language. The examples range from simple mathematical and date functions to more complex systems with graphical user interfaces.

Uploaded by

Keith Lee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Software Testing A Craftsman s Approach 4th

Full chapter at: https://testbankbell.com/product/software-testing-a-craftsman-s-approach-4th-jorgensen-solution-manual/

Chapter 2

Examples

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


About Pseudo-code

• Language neutral
• Supports both procedural and
object-oriented code
• Easy to “translate” into your
favorite programming language

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


Examples

• Triangle problem
• NextDate
• Commission problem
• Simple ATM system
• Currency converter
• Windshield Wiper controller
• Garage door controller

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


Triangle Problem
Simple version: The triangle program accepts three integers, a, b, and c, as input.
These are taken to be sides of a triangle. The output of the program is the type of
triangle determined by the three sides: Equilateral, Isosceles, Scalene, or Not A
Triangle.
Improved version: “Simple version” plus better definition of inputs:
The integers a, b, and c must satisfy the following conditions:
c1. 1 ≤ a ≤ 200 c4. a<b+c
c2. 1 ≤ b ≤ 200 c5. b<a+c
c3. 1 ≤ c ≤ 200 c6. c<a+b
Final Version: “Improved version” plus better definition of outputs:
If an input value fails any of conditions c1, c2, or c3, the program notes this with an
output message, for example, “Value of b is not in the range of permitted values.” If
values of a, b, and c satisfy conditions c1, c2, and c3, one of four mutually exclusive
outputs is given:
1. If all three sides are equal, the program output is Equilateral.
2. If exactly one pair of sides is equal, the program output is
Isosceles.
3. If no pair of sides is equal, the program output is Scalene.
4. If any of conditions c4, c5, and c6 is not met, the program output
is NotATriangle.

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


Triangle Problem Discussion
Final Version: “Improved version” plus better definition of outputs:
If an input value fails any of conditions c1, c2, or c3, the program notes this
with an output message, for example, “Value of b is not in the range of
permitted values.” If values of a, b, and c satisfy conditions c1, c2, and c3,
one of four mutually exclusive outputs is given:
1. If all three sides are equal, the program output is Equilateral.
2. If exactly one pair of sides is equal, the program output is
Isosceles.
3. If no pair of sides is equal, the program output is Scalene.
4. If any of conditions c4, c5, and c6 is not met, the program output is
NotATriangle.

Problems persist! What output is expected for the input set (2, 2, 5)?
• Isosceles because a = b?
• NotATriangle because c > a+b?

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


Triangle Problem Exercise

Fix the “Final Version” (sometimes testers must also be


specifiers!)

The Really Final Version: “Improved version” plus better


definition of outputs.

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


NextDate

NextDate is a function of three variables: month, date, and year. It returns


the date of the day after the input date. The month, date, and year variables
have integer values subject to these conditions:
c1. 1 ≤ month ≤12
c2. 1 ≤ day ≤ 31
c3. 1812 ≤ year ≤ 2012

If any of conditions c1, c2, or c3 fails, NextDate produces an output


indicating the corresponding variable has an out-of-range value — for
example, “Value of month not in the range 1..12”. Because numerous invalid
day–month–year combinations exist, NextDate collapses these into one
message: “Invalid Input Date.”

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Commission Problem

A rifle salesperson in the former Arizona Territory sold rifle locks, stocks, and
barrels made by a gunsmith in Missouri. Locks cost $45, stocks cost $30,
and barrels cost $25. The salesperson had to sell at least one complete rifle
per month, and production limits were such that the most the salesperson
could sell in a month was 70 locks, 80 stocks, and 90 barrels. After each
town visit, the salesperson sent a telegram to the Missouri gunsmith with the
number of locks, stocks, and barrels sold in that town. At the end of a month,
the salesperson sent a very short telegram showing –1 locks sold. The
gunsmith then knew the sales for the month were complete and computed
the salesperson’s commission as follows: 10% on sales up to (and
including) $1000, 15% on the next $800, and 20% on any sales in excess of
$1800. The commission program produced a monthly sales report that gave
the total number of locks, stocks, and barrels sold, the salesperson’s total
dollar sales, and, finally, the commission.

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Simple ATM (SATM) System

• Deliberately simple (only 15 screens)


• Very familiar example
• Full description in text

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Simple ATM (SATM) Terminal

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Currency Converter
The currency conversion program is another event-driven program that
emphasizes code associated with a graphical user interface (GUI).

Currency Converter
U.S. Dollar amount
Equivalent in ...

Brazil
Compute
Canada
Clear
European community
Quit
Japan

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Saturn Windshield Wiper Controller

The windshield wiper on some Saturn automobiles is controlled by a


lever with a dial. The lever has four positions, OFF, INT (for intermittent),
LOW, and HIGH, and the dial has three positions, numbered simply 1, 2,
and 3. The dial positions indicate three intermittent speeds, and the dial
position is relevant only when the lever is at the INT position. The
decision table below shows the windshield wiper speeds (in wipes per
minute) for the lever and dial positions.

c1. Lever OFF INT INT INT LOW HIGH

c2. Dial n/a 1 2 3 n/a n/a

a1. Wiper 0 4 6 12 30 60
speed is…

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Garage Door Controller
• This is an example for Systems of Systems
• Constituent systems
– a drive motor
– a drive chain
– the garage door wheel tracksensors
– a lamp
– an electronic controller
• Communication devices
– wireless keypad (usually in an automobile)
– a digit keypad on the outside of the garage door
– a wall-mounted button.
• Safety features
– a light beam near the floor
– an obstacle sensor

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples


The Garage Door Controller
(shown here as a SysML Context Diagram)

Software Testing: A Craftsman’s Approach, 4th Edition Chapter 2 Examples

You might also like