Introducci - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Introducci

Description:

Given all student's ages in certain class print if each one can vote or not ... OV: Sign stating if the student can vote or not (S) Operators: ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 9
Provided by: ites2
Category:
Tags: class | introducci

less

Transcript and Presenter's Notes

Title: Introducci


1
I. 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.
2
II. 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
3
II. Analysis
After asking almost everyone, I have one more
student to check
4
II. 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
5
II. 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

6
III. Design Algorithm and/or Pseudo Code
  1. Start
  2. Type the Total number of students
  3. Save it into input variable T
  4. Type a students Age
  5. Save it into input variable A
  6. Compare A gt 18, if the result is true (yes) then
    the output variable S can, else (false/no) S
    cant
  7. Print S
  8. Reduce the counter T by one
  9. Compare T 0, if the result is true (yes) then
    go to the end, else (false/no) go to step no. 4
  10. End

7
III. Design Flow Chart
END
1
8
IV. 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
Write a Comment
User Comments (0)
About PowerShow.com