Exercise 2.4. (Boundary testing the if ... else Selection Construct)
1. Ensure you have viewed the video (associated with this exercise) at this link >>
2. For the following program what is the testing boundary? What values should you enter to fully test the program?
Exerise 2.4. Example 1
3. For the following specification produce a Design (Structured English or Nassi–Shneiderman Diagram), a Data Table, Test Plan with full boundary testing, and a Python program. Test your Python program against the Test Plan.
Specification
Citizens of a country who are 16 and above can vote in a referendum. Write a program that asks users to enter their age. If they are old enough to vote the program informs them that they can vote. However, if they are not old enough to vote the program tells them that they cannot vote.
Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.
Specification
Citizens of a country who are 16 and above can vote in a referendum. Write a program that asks users to enter their age. If they are old enough to vote the program informs them that they can vote. However, if they are not old enough to vote the program tells them that they cannot vote.
Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.
4. For the following specification produce a Design (Structured English or Nassi–Shneiderman Diagram), a Data Table, Test Plan with full boundary testing, and a Python program. Test your Python program against the Test Plan.
Specification
Have a program read either a positive or negative integer entered at the keyboard by the user. The program is required to print whether the integer entered is either positive or negative. For the purpose of this exercise regard 0 (zero) as being positive. To accomodate this have the ouputs from the program be one of the following strings.
Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.
Specification
Have a program read either a positive or negative integer entered at the keyboard by the user. The program is required to print whether the integer entered is either positive or negative. For the purpose of this exercise regard 0 (zero) as being positive. To accomodate this have the ouputs from the program be one of the following strings.
- The number entered is either 0 or positive
- The number entered is negative
Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.
END Next Exercise >>