Documente Academic
Documente Profesional
Documente Cultură
Week:
Lecture Date:
Course:
Instructor:
Topic:
11
18/04/2012
Computing Fundamental
Dr. Arif Mushtaq
Software Development Methods
5/8/2012
Computer Programming
2.
3.
4.
5.
6.
5/8/2012
Decomposition
Flowcharting
Pseudocode
1.
2.
3.
4.
5.
5/8/2012
Example
Problem statement
Example
3. Design the algorithm
a. Flowcharting - Flowcharting is a graphical way of
depicting a problem in terms of its inputs, outputs, and
processes.
5/8/2012
Example
Since
our
processing is
complete, we
should display
the output for
the user.
Example
3. Design the algorithm
b. Pseudocode
It is important to note that each time you compute a value that you will need later,
it is necessary to store it even if you will need it right away.
5/8/2012
Exercise
You have a store that sells apples and oranges. Apples are
Rs. 10 each and oranges are Rs. 5 each. Your program
should get from the user the number of apples and
oranges and output the total amount of money.
5/8/2012
5/8/2012
5/8/2012
5/8/2012
10
5/8/2012
Modified example:
If it is raining, tell the user to get an umbrella. Otherwise,
say it is sunny.
The extension of this concept in our flowchart is simply do
something with the no branch.
In pseudocode, we add the else, or condition not true,
case.
If it is raining, tell user to get an umbrella else tell
the user that it is sunny.
Flowchart and pseudocode for the modified example is
given next.
11
5/8/2012
Exercise
Week:
Lecture Date:
Course:
Instructor:
Topic:
12
08/05/2012
Computing Fundamental
Dr. Arif Mushtaq
Software Development Methods
12
5/8/2012
Conditions
Conditions
13
5/8/2012
Conditions
Notice that the > 16 case does not appear in the conditional
expression. Because of this obvious consequence, our flowchart
and pseudocode do not have to explicitly state the final case.
This is known as the default case.
Conditions
14
5/8/2012
Exercise
Conditions-Example
15
5/8/2012
Exercise 1
Write down an algorithm for each of the following
problems:1. Find the average of four numbers.
2. Change the time in seconds to minutes.
3. Find the product of two numbers (this
means to multiply the two numbers).
4. Find the difference between two numbers.
Exercise 2
Write a program that tells the user what type of movie they
can attend based on their age, if they are with their
parents, and their amount of money.
Under 13:
G
Under 13 w/ parent:
G, PG
13 and Over and Under 16:
G, PG
Under 16 w/ parent:
G, PG, R
16 and Over:
G, PG, R
Morning:
$7.50
Evening:
$10.50
16
5/8/2012
Morning
Morning
Exercise 3
Write a program that will take as input the users bank
account balance, the type and level of account they have.
Based on this information and the below rate table,
determine the interest rate they are receiving.
17
5/8/2012
Exercise-4
Write a program that will take as input the type of
restaurant the user ate at, the cost of the meal, the number
of people in his/her party, and how good the service was.
Determine the dollar amount of the tip:
18