Output “Funds not available” Thinking Logically Identify the points in a solution where a decision has to be taken Identify the points in this program where a decision has to be taken. Give an example of code (language of your choice) that would implement this Flow Diagram. While Pin= False: Pin = input(“Please enter Pin”) Check Pin Pin = False Else: amount = input(“Enter amount:”) Pin = True …… etc Is PIN correct Input Card Start Stop Input PIN Enter amount Check PIN Check funds available Are funds available? Activate speaker Output cash Print receipt Update balance NO YES Output confirmation Output “Funds not available” YES
Thinking Logically Identify the points in a solution where a decision has to be taken In a unit 2 exam, you will need to be able to identify the points in a pseudocoded problem where a decision has to be taken. Throughout the course you have been programming to prepare for this. In this activity you need to choose at least 3 programs you have written. Using the table on the following slide identify the various points in your solutions where your program had to make a decision. Make sure to choose a variety of different programs
Decision points in solution Thinking Logically Identify the points in a solution where a decision has to be taken Title of program What does it do? Decision points in solution National_lottery_sim Program which simulates the national lottery draw by producing 6 random numbers when ENTER is pressed DECISION POINT 1: Has ENTER been pressed DECISION POINT 2: Has the random generated number already been picked DECISION POINT 3: Have 6 unique numbers been drawn Card Machine Balance Program that checks a balance in a account and allows a customer to withdraw money from that amount Decision 1: Is amount smaller than 250? Greatest Number Program that allows two numbers to be picked and displays the larger one Decision 1: Is number 1 greater than number 2? Water Temperature Allows a temperature to be entered and shows whether the water is boiling, frozen or normal Decision 1 : Is the temperature less than zero? Decision 2: Is the temperature more than a hundred?
Output “Funds not available” Thinking Logically Determine the logical conditions that affect the outcome of a decision Determine the various logical conditions that affect the outcome of the decision points in this program. Is PIN correct Input Card Start Stop Input PIN Enter amount Check PIN Check funds available Are funds available? Activate speaker Output cash Print receipt Update balance NO YES Output confirmation Output “Funds not available”
Thinking Logically Determine the logical conditions that affect the outcome of a decision In a unit 2 exam, you will need to be able to determine the various logical conditions that affect the outcome of a decision based on pseudocoded examples. Throughout the course you have been programming to prepare for this. In this activity you need to choose at least 3 programs you have written. Using the table on the following slide identify the various logical conditions that affect the outcome of decisions in your program. Make sure to choose a variety of different programs
Thinking Logically Determine the logical conditions that affect the outcome of a decision Title of program What does it do? Logical conditions National_lottery_sim Program which simulates the national lottery draw by producing 6 random numbers when ENTER is pressed IF (ENTER has been pressed) THEN… IF (New_num_generated == Any previous selected numbers) THEN… REPEAT UNTIL (Total_unique_num_generated = 6)…
Output “Funds not available” Thinking Logically Determine how decisions affect flow through a program Explain how the decisions being made in this program would affect the flow through the program. If the Pin is incorrect multiple times then the program will take longer to finish, and will keep going in circles until the Pin is correct. If the amount is also wrong it will do the same thing, display an error and circle back around so that it can be entered again. The program would only be most efficient in time-wise if both the Pin and the Amount were valid. Is PIN correct Input Card Start Stop Input PIN Enter amount Check PIN Check funds available Are funds available? Activate speaker Output cash Print receipt Update balance NO YES Output confirmation Output “Funds not available”
Thinking Logically Exam style question Procedure take from stack(old,item) If pointer = minimum Then Stack_empty = True Else pointer = pointer – 1 stack[pointer] = old,item Endif End Procedure Maximum ‘If pointer = maximum Then’ checks if the pointer is full or not.