Flowcharts l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 42

Flowcharts PowerPoint PPT Presentation


  • 137 Views
  • Uploaded on
  • Presentation posted in: General

Flowcharts. Lecture 12. Symbol. Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in an algorithm. Process Symbol: Represents any single process in an algorithm. Predefined Process Symbol:. Decision Symbol:

Download Presentation

Flowcharts

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Flowcharts l.jpg

Flowcharts

Lecture 12


Symbol l.jpg

Symbol

Terminal Symbol:

indicates the starting or stopping pointin the logic.

Input/Output Symbol:

Represents an input or output process in an algorithm

Process Symbol:

Represents any single process in an algorithm

Predefined Process Symbol:

Decision Symbol:

Represents a decision in the logic involving the comparison

Of two values.


The three basic control structures l.jpg

The three basic control structures


1 sequence l.jpg

1. Sequence

Statemement a

Statemement b

Statemement c


2 selection l.jpg

2. Selection

Condition p?

T

F

Statemement a

Statemement b


Selection 2 l.jpg

Selection (2)

Condition p?

F

T

Statemement a


3 repetition l.jpg

3. Repetition

Condition p?

F

T

Statemement block


Example 12 1 add three numbers l.jpg

Example 12.1 Add three numbers

  • A program is required to read three numbers, add them together and print their total.


Slide9 l.jpg

  • Defining diagram


Solution algorithm l.jpg

Solution Algorithm

Start

Read

Number1

Number2

number3

Add numbers to total

Print total

Stop


Example 12 2 find average temperature l.jpg

Example 12.2 Find average temperature

  • A program is required to prompt the terminal operator for the maximum and minimum temperature readings on a particular day, accept those readings as integers, and calculate and display to the screen the average temperature, calculated by (maximum temperature + minimum temperature)/2.


Slide12 l.jpg

  • Defining diagram


Solution algorithm13 l.jpg

Solution Algorithm


Example 12 3 compute mowing time l.jpg

Example 12.3 Compute mowing time

  • A program is required to read from the screen the lenght and widht of a rectangular house block, and the lenght and width of the rectangular house that has been built on the block. The algorithm should then compute and display the mowing time required to cut the grass around the house, at the rate of two square metres per minute.


Slide15 l.jpg

  • Defining diagram


Solution algorithm16 l.jpg

Solution Algorithm


Flowchart and the selection control structure l.jpg

Flowchart and the selection control structure


Simple if statement l.jpg

Simple IF statement

Account_

balance <

$300?

T

F

Service_charge = $5

Service_charge = $2


Null else statement l.jpg

Null ELSE statement

Student_

attendance =

P/T?

F

T

Increment

part_time_count


Combined if statement l.jpg

Combined IF statement

Student =

P/T AND

Gender =

F ?

F

T

Increment

Female_part_time_count


Nested if statement l.jpg

Nested IF statement

T

Record

Code =`A‘ ?

F

F

T

Record

Code =`A‘ ?

Increment

Counter_A

Record

Code =`A‘ ?

F

Increment

Counter_B

T

Increment

Error_counter

Increment

Counter_C


Example 12 4 read three characters l.jpg

Example 12.4 Read three characters

  • Design an algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen.


Slide23 l.jpg

  • Defining diagram


Solution algorithm24 l.jpg

Solution Algorithm ?


Case structure l.jpg

Case Structure

Case

Of

variable

Value 2

Value 3

Value 4

Value 1

Statement_a

Statement_b

Statement_c

Statement_d


Flowchart and array l.jpg

Flowchart and Array

  • Design a program that will prompt for and receive 18 examination scores from a mathematics test, compute the class average, and display all the scores and the class average to the screen.


Slide28 l.jpg

  • Defining diagram


Control structures required l.jpg

Control Structures required

  • An array to store the exam scores – called ´scores´

  • An index to identify each element in the array

  • A DO loop to accept the scores

  • Another DO loop to display the scores to the screen.


Solution algorithm30 l.jpg

Solution Algorithm

Start

Calculate

average

Display

average

Total_score =

zero

I = 1

I = 1

Stop

Prompt and

get

Scores (I)

Display

Scores (I)

Add scores(I)

to

Total score

I = I + 1

T

I = I + 1

I <= 18 ?

F

T

I <= 18 ?

F


Flowchart and module l.jpg

Flowchart and Module

Design a solution algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen. The algorithm is to continue to read characters until ´XXX`is entered.


Slide32 l.jpg

  • Defining diagram


Hierarchy chart l.jpg

Hierarchy chart

Process_three_

characters

Sort_three_

characters


Process three characters l.jpg

Process_three_characters

Start

Sort_

Three_

characters

Prompt

For

characters

Outpur

characters

Get

characters

Prompt

For

characters

Characters

NOT = xxx ?

F

Stop

Get

characters

T


Sort three characters l.jpg

Sort_three_characters

Start

T

Char_1 >

Char_2 ?

F

Swap

Char_1,

Char_2

Char_2 >

Char_3 ?

T

F

Swap

Char_2,

Char_3

Char_1 >

Char_2 ?

T

F

Swap

Char_1,

Char_2

Stop


Assignment calculate employee s pay l.jpg

Assignment: Calculate Employee‘s pay

A program is required by a company to read an employee‘s number, pay rate and the number of hours worked in a week. The program is then to validate the pay rate and the hours worked fields and, if valid, compute the employee‘s weekly pay and print it along with the input data.


Assignment cont l.jpg

Assignment (cont‘)

Validation: According to the company‘s rules, the maximum hours an emplooye can work per week is 60 hours, and the maximum hourly rate is $25.00 per hour. If the hours worked field or the hourly rate field is out of range, the input data and an appropriate message is to be printed and the emplooye‘s weekly pay is not to be calculated.

Weekly pay calculation: Weekly pay is calculated as hours worked times pay rate. If more than 35 hours are worked, payment for the overtime hours worked is calculated at time-and half.


Slide38 l.jpg

  • Defining diagram


Hierarchy chart39 l.jpg

Hierarchy chart

Compute_employee_pay

Employee_details

Valid_input_

fields

Read_employee_

details

Validate_input_

fields

Calculate_

Employee_pay

Print_employee_

details


Solution algorithm40 l.jpg

Solution Algorithm


Compute employee pay l.jpg

Compute_employee_pay

Fields

Valid?

Start

Read_

Employee_

details

Calculate_

Employee_

pay

More

Recods?

Print_

Employee_

details

Validate_

Input:

fields

Stop

Read_

Employee_

details


Validate input fields l.jpg

Validate_input_fields

Start

Hours_

Worked

> 60

Valid_input_

fields = T

Print

Error

message

Pay_rate

> $ 25

Print

Error

message

Valid_

Input_

Fields = T

Valid_

Input_

Fields = F

Stop


  • Login