Page 99 - Computer Science Class 11 With Functions
P. 99

The flowchart for the above pseudocode is given below (Fig 4.8):


                                                               Start


                                                             input n



                                                 False                     True
                                                            n % 2 == 0


                                        print "Odd"                             print "Even"




                                                              Stop

                                 Fig 4.8: Flowchart to check whether the user entered number is even or odd

            Validating User's Key on a Mobile: All of us have used smartphones. A smartphone provides a simple security feature
            that guards against unauthorized use of the smartphone. When a user buys a smartphone, they can set a secret key (also
            called a password) of their choice. The phone gets automatically locked when not in use for some time (typically a few
            seconds to a minute, as per the user settings). To use the smartphone again, the user needs to enter the password. The
            input entered by the user (let us call it userkey) is matched against the password stored in the smartphone's memory. As
            a user might enter a wrong key accidentally, the smartphone allows a certain number (typically five) of failed attempts.
            After the allowable limit on failed attempts, to avoid repeated failed attempts in quick succession, the smartphone gets
            locked for a longer period (say, one minute). Below we develop a flowchart for unlocking the smartphone.

                                                  Start



                                                                  Counter = 0



                                                                  input userkey




                                                     False
                                                                  counter <= 5


                                                                        True
                                                            Yes
                                                                   userkey ==
                                                                   password

                                                                         No
                                                               Increment counter by 1

                                            Phone locked for
                                             longer duration  Phone Unlocked!



                                                 Stop
              Fig 4.9: Flowchart to unlock a smartphone. It validates the user input (userkey) against the password saved in a smartphone.


                                                                                                Problem Solving  97
   94   95   96   97   98   99   100   101   102   103   104