Week 3 Homework
Week 3 Homework
SWENG 581
Week 3
11/07/2019
Chapter 6
Exercises
5
Consider
the three domains D1, D2, and D3 shown in Figure 6.16. Domain D3 consists of all those
points lying on the indicated straight line. Assuming that the maximum X and Y span of
all the three domains are [−5, 5] and [−5, 5], respectively, give
concrete values of test points for domain D3.
The concrete values for test points of D3 are (-5,-5), (-4,-4), (-3,-3), (-2,-2), (-1,-1), (0,0), (1,1),
(2,2), (3,3), (4,4), (5,5). The X and Y coordinates are the same because it is straight line passing
through the origin. How did I get those values? Domain D3 is represented by an equation X = Y.
Chapter 9
Exercises 5
Consider the following triangle classification system, originally used by Myers [16]: The
system reads in three positive values from the standard input. The three values A,B, and C
are interpreted as representing the lengths of the sides of a triangle. The system then prints
a message on the standard output saying whether the triangle is scalene, isosceles,
equilateral, or right angled if a triangle can be formed. Answer the following questions for
the above program:
(A) What is the input domain of the system?
Input domain of the system is the inputs passed to the program. i.e Three side lengths of the
Triangle under test.
Input conditions are valid inputs and invalid inputs. For length of triangle side input, we require a
positive side length. A valid input to the program returns a valid program output. An invalid input
is an input the program responds with an error.
Invalid input:
Equivalence classes are test case execution minimization techniques. An equivalence class is a
set of inputs that the program treats as identical.
EqClass_NotTriangled
EqClass_Invalid2
EqClass_Invalid3;
(D) Identify test cases to cover the identified ECs?
TestInputs Outputs
Sample Program:
/*
* TriangleClassification Program
*
*/
// Constructor
public TriangleClassification(int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
}
return outputMessage;
}
Exercises 7
Consider the triangle classification specification. The system reads in three positive values
from the standard input. The three values A,B, and C are interpreted as representing the
lengths of the sides of a triangle. The system then prints a message to the standard output
saying whether the triangle, if it can be formed, is scalene, isosceles, equilateral, or not a
triangle. Develop a decision table to generate test cases for this specification.
The decision table is a tool for requirements management and testing. It is used to model complicated
logic. Decision table testing technique that tests a system behavior for many input combinations. This is a
systematic process of capturing the different input combinations with their system behavior as an output,
in a tabular form. Decision table is a testing technique which used to test the system outcomes possibly
for every input provided to the program. Then, these outcomes are stored in the form of records in tables
which tells about the behavior of the program. This is the one reason why this table is also called a
Cause-Effect table.
● The condition to form a triangle is constraint by the law that is, the sum of the two smaller sides is
always greater than the third side.
● If all three sides are equal then it is an equilateral triangle, if only two are equal then isosceles
otherwise, it is a scalene.
Possible Cases 1 2 3 4 5 6 7 8 9 10 11
C2: a = b? - - - T T T T F F F F
C3: a = c? - - - T T F F T T F F
C4: b = c? - - - T F T F T F T F
A2: Scalene X
A3: Isosceles X X X
A4: Equilateral X
A5: Impossible X X X
If you ask me, what does the X's correlate to? I see it means "is true". is that only for the first 3 numbers
since there are only max 3 X's?
Due to format restrictions proper table Symbol has been shifted I will consider these not a triangle cases
will be 1,2,3 and SCALENE will be 11 case, EQUILATERAL will be 4 case, ISOSCELES will be 7,9,10
cases and IMPOSSIBLE CASES will be 5,6,8.
However, X means this following case is true. And every case will have different condition satisfaction as
I mentioned above in CASE 1,2,3 triangles will not form, whereas triangle will be formed in 11(scalene),
4 (equilateral), 7,9 and 10 (isosceles) for the rest of the case it is impossible 5,6 and 8.
✔ a = b?
✔ a = c?
✔ b = c?
2. I did calculate the number of possible combinations
//
//#include "stdafx.h"
#include<iostream>
//Add namespace
class Triangle
//Declare variables
float a, b, c;
public:
void input();
void TriangleType();
};
void Triangle::TriangleType()
if (a == b == c)
|| ((c * c) + (b * b) == a * a))
cout << "\n These sides are unable to make a triangle. Pls try again.";
else
void Triangle::input()
{
cout << "Enter the sides of the triangle.";
try {
cin >> a;
if (a < 0)
throw a;
cin >> a;
cin >> a;
try {
cin >> b;
if (b < 0)
throw b;
cin >> b;
cin >> b;
try {
cin >> c;
if (c < 0)
throw c;
cin >> c;
cout << "\nNegative numbers are not allowed.\nPls again enter the value: ";
cin >> c;
int main()
Triangle ob;
char ch;
do {
ob.input();
ob.TriangleType();
Task 3: A bank has several different levels of awards/penalties that it showers on its customers.
Both are based on the amount of dollars in customers’ various accounts. Different types of
accounts are calculated differently, even though the trigger amounts are the same for all
accounts. The simple rules for any given period are as follows:
Balances at or below $1,000 are penalized by low interest. While Balances above $1,000 get full
interest.
Which test cases from the following represent "Boundary Value Analysis" technique?
I. Testing with invalid account
✔ II. Testing with balances of $999, $1000, $1001
III. Testing with balances of $990, $995, $999
IV. Testing with a Zero Balance
Task 4: For a certain program that controls a thermostatic switch, the switch is switched off once
the temperature falls below 18 F and then it is turned on when the temperature is more than 21 F.
Identify the Equivalence values which belong to the same class.
I. 12,16,22
II. 24,27,17
III. 14,15,19
✔ IV. 22,23,24
I. code inspection