21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

280 Chapter 19 ■ Testing<br />

19.3 Devise black box and white box test data to test the following program. The program<br />

specification is:<br />

The program is to determine insurance premiums <strong>for</strong> a holiday, based upon the<br />

age and gender (male or female) of the client.<br />

For a female of age >= 18 and = 31<br />

pays $3.50. A male of age >= 18 and = 36 pays $5.50.<br />

People aged 50 or more pay half premium. Any other ages or genders are an error,<br />

which is signaled as a premium of zero.<br />

The Java code <strong>for</strong> this program is:<br />

public float calcPremium(float age, String gender) {<br />

float premium;<br />

}<br />

if (gender.equals("female"))<br />

if ((age >= 18) && (age = 31)<br />

premium = 3.50f;<br />

else<br />

premium = 0.0f;<br />

else<br />

if (gender.equals("male"))<br />

if ((age >= 18) && (age = 36)<br />

premium = 5.5f;<br />

else<br />

premium = 0.0f;<br />

else<br />

premium = 0.0f;<br />

if (age >= 50)<br />

premium = premium * 0.5f;<br />

return premium;<br />

19.4 Suggest features <strong>for</strong> software tools that could assist in using each of the following<br />

techniques:<br />

■ black box testing<br />

■ white box testing.<br />

19.5 Substantial testing of a system uncovers not a single error. What conclusions would<br />

you draw?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!