Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms A Central Heating system Start Is temp <19

Similar presentations


Presentation on theme: "Algorithms A Central Heating system Start Is temp <19"— Presentation transcript:

1 Algorithms A Central Heating system Start Is temp <19
Turn Heating on Is temp >20 Turn Heating off

2 Algorithms Calculate the area of a rectangle What mathematical calculation do you have to perform on these two inputs? What two inputs do you need to calculate the area of a rectangle? Height Width Multiplication

3 Start Input width Input Height Area = width x height OUTPUT area Stop

4 Pseudocode Input value If value >= 1 THEN If value >= 10 THEN
Output “value OK Else Output “value not OK” ENDIF Return to input

5 Input key If key arrow pressed Move left Move right Move down Move up

6 Pseudocode Press key If key = right arrow THEN move right Else
If key = left arrow THEN move left If key = up arrow THEN move up If key = down arrow THEN move down ENDIF

7 A garden centre has a loyalty card scheme that gives members a 10% discount if they spend more than £50. If any customer spends more than £100, then they get a 5% discount on top of any discounts they may already have. Create a flow chart to show how this program might work

8 Start No disc No disc Disc = 15% Disc = 10% YES NO NO NO YES YES YES
Loyalty card Spend > £100 Spend > £50 YES NO NO No disc NO Loyalty card Taken out YES YES YES NO No disc Disc = 15% Disc = 10%

9 Start No disc Disc = 10% Disc 5% Disc = 15% NO YES NO YES NO YES
Loyalty card Spend > £50 No disc YES NO NO YES Disc = 10% Spend > £100 Disc 5% NO YES Disc = 15%

10 Start No disc Disc = 15% Disc = 10% NO NO YES NO YES YES Loyalty card
Spend > £100 Spend > £50 NO NO No disc YES NO YES YES Disc = 15% Disc = 10%

11 Start Loyalty card scheme No disc Disc 5% Disc = 10% Disc = 15% NO NO
Spend > £100 Spend > £50 NO NO No disc YES YES Loyalty card Loyalty card YES NO NO YES Disc 5% Disc = 10% Disc = 15%

12 Pseudocode INPUT spend INPUT loyalty card IF spend > 100 THEN
IF loyalty card = YES THEN discount = 15% ELSE IF loyalty card = NO THEN discount = 5% ENDIF ENDIF IF spend < 100 THEN IF spend > 50 THEN IF loyalty card = YES THEN discount = 10% ELSE IF loyalty card = NO THEN no discount ENDIF ENDIF ENDIF IF spend < 50 THEN no discount ENDIF


Download ppt "Algorithms A Central Heating system Start Is temp <19"

Similar presentations


Ads by Google