Professional Documents
Culture Documents
[ITPPA1]
Eduvos (Pty) Ltd (formerly Pearson Institute of Higher Education) is registered with the Department of Higher Education and Training as a private higher education institution under the
Higher Education Act, 101, of 1997. Registration Certificate number: 2001/HE07/008
Week 4: Lesson 1
Introduction
• To process a program, the computer begins at the first executable statement and
executes the statements in order until it comes to the end. It can also make
decisions and repeat certain statements over and over until certain conditions are
met. This week we will look at the decision and repetition structures .
What will be covered in
today’s lesson?
Decision/Selection
Week 1 Structures
Lesson 1
Repetition
structures
Control Structures
Write a program that mimics a calculator. The program should take as input
two integers and the operation to be performed. It should then output the
numbers, the operator, and the result. (For division, if the denominator is
zero, output an appropriate message.) Some sample outputs follows:
Selection Structure
Suppose that classStanding is a char variable, gpa and dues are double
variables. Write a switch expression that assigns the dues as following: If
classStanding is 'f', the dues are $150.00; if classStanding is 's', (if gpa is at
least 3.75, the dues are $75.00; otherwise dues are 120.00); if classStanding
is 'j', (if gpa is at least 3.75, the dues are $50.00; otherwise dues are
$100.00); if classStanding is 'n', (if gpa is at least 3.75, the dues are $25.00;
otherwise dues are $75.00). (Note that the code 'f' stands for first year
students, the code 's' stands for second year students, the code 'j' stands
for juniors, and the code 'n' stands for seniors.)
Repetition Structures
What Happens Next?
Arrays