ITEC1620 ObjectBased Programming - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

ITEC1620 ObjectBased Programming

Description:

ITEC1620. Object-Based Programming. Lecture 2b. Structured Programming III ... Make a decision in a loop. etc. Lecture 2b - Structured Programming III. 4 ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 16
Provided by: atkinso
Category:

less

Transcript and Presenter's Notes

Title: ITEC1620 ObjectBased Programming


1
ITEC1620Object-Based Programming
  • Lecture 2b
  • Structured Programming III

2
Review
  • 3 structures of structured programming
  • Sequence
  • Perform an action
  • Branch
  • Select an action (or no action)
  • Loop
  • Repeat an action

3
Nested Control Structures
  • Structured programming involves designing an
    algorithm by using the three structures
  • Structures can be nested/embedded
  • Select between two loops
  • Make a decision in a loop
  • etc

4
Sample ProgramDecision in a Loop
  • Write a program that tells a user if their next
    guess of a random number (1-10) needs to be
    higher or lower
  • Declare and initialize random number
  • Declare and get guess
  • While guess not correct
  • Decide if guess was too high or too low

5
(No Transcript)
6
Sample Program IIOptional Loops
  • Write a program that outputs all of the integers
    from 0 to an input number
  • Declare and get input
  • If input is positive
  • Loop from 0 to input
  • Otherwise, loop from 0 to input

7
(No Transcript)
8
Sample Program IIINested Loop
  • Write a program that prints out an hourly
    timetable for a seven-day week
  • Loop for seven days
  • Loop for 24 hours
  • Print time slot

9
(No Transcript)
10
Sample Program IVTelephone Banking
  • Write a program that implements an ATM interface
  • 1 get balance
  • 2 deposit
  • 3 withdraw
  • 9 end session

11
(No Transcript)
12
Sample Program VClass average and pass/fail
  • Write a program that allows grades to be entered
    (-1 to exit) and calculates the class average and
    the number of students that passed
  • Pass is 60

13
(No Transcript)
14
Questions?
15
Readings and Assignments
  • Assignment 1 Iconic Programming
Write a Comment
User Comments (0)
About PowerShow.com