Title: Introducci
1I. Definition
Given all student's ages in certain class print
if each one can vote or not until the last
student gives his age. Hint The teacher needs
to input the total number of students in class.
2II. Analysis
You need at least 18 to vote
I have N students in my class, so still need to
ask to N-1
Give me your Age.
Yes/no, you can/cant vote
3II. Analysis
After asking almost everyone, I have one more
student to check
4II. Analysis
You need at least 18 to vote
I have N students in my class, but I asked
everyone, so I have finished
Give me your Age.
Yes/no, you can/cant vote
5II. Analysis
- Constants There are no constants in this problem
- Variables
- IV1 Age (A)
- IV2 Total number of students (T)
- OV Sign stating if the student can vote or not
(S) - Operators
- OP1 Relational, gt (greater than or equal)
- OP2 Relational, (equal)
- OP3 Arithmetic, - (subtraction)
- Operations
- A gt 18
- T T -1 (This is a counter reduction by one)
- T 0
6III. Design Algorithm and/or Pseudo Code
- Start
- Type the Total number of students
- Save it into input variable T
- Type a students Age
- Save it into input variable A
- Compare A gt 18, if the result is true (yes) then
the output variable S can, else (false/no) S
cant - Print S
- Reduce the counter T by one
- Compare T 0, if the result is true (yes) then
go to the end, else (false/no) go to step no. 4 - End
7III. Design Flow Chart
END
1
8IV. Test (Assign input variables some Run Test
values)
- Start
- C 38
- A 20
- A gt 18?
- True
- S can
- You can vote
- C 38 1
- C 37
- 9. C0?
- 10. False
- A 15
- A gt 18?
- False
- S cant
- You cant vote
- C 37 1
- C 36
- 18. C0?
- 19. False
-
-
A 18 A gt 18? True S can You can vote C
1 1 C 0 C0? True End