Exercises

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

OU BUILD EXERCISES

EXERCISE 1 SIMPLE LOGON


• You are asked to create a program that checks whether the user input matches
the Pin code 1234.
• If the pin is correct the program should play a computer beep sound and
display a Welcome User message, if incorrect an Incorrect Pin error message
should be displayed

EXTENSION : PROMPT FOR THREE ATTEMPTS

This time when users enter an incorrect password they get a message saying,
“Incorrect password” followed by a message saying “Please enter your password

If they do enter the password incorrectly after three attempts they get a message
saying, “Access denied” followed by a message saying “Your account has been
locked

GUESSING GAME ALGORITHM

Can you implement the program from given algorithm, starter project has been given to help
you?

Set computers number to random number between 1 and 10


Repeat until users guess equals q
Prompt for user guess
Store user input in users guess variable
If users guess is equal to computers number
Display winning message
Stop script
Else
Display bad luck message
GUESSING GAME

• You have been asked to modify a simple guessing game. The application works
by allowing a user to guess a number between 1 and 10 randomly chosen by
the computer.
• The program will first generate a random number between 1 and 10 and then
repeatedly prompt for the users guess until they enter a terminating value of
‘q’
• When the user guesses the correct answer an winning message will be
displayed on screen and the program will stop.
• You need to modify the program to give the user hints let them know if their
number is too high or too low

EXTENSION : -

 limit number of guesses to 3 display game over you lost message if more
than 3 guesses
SHOPPING LIST

• You have been asked to create an application that allows a user to create a
shopping list when the application is started by entering the values
sequentially until a terminatory value (end) is entered.
• The application must also display each item in the list when the space bar is
pressed.
• Create an algorithm for doing so.

CHECK PASSWORD

• A Requirement has been made to check that a password chosen by a user


meets the complexity requirements set by the administrator.
• These are that the password must be 8 characters long, contain at least one
special character and at least one digit.
• Design an algorithm to do so.
GET WINNER

• A Requirement has been made to calculate the winning time from a list of
times
• Design an algorithm, to do so

GET SECOND PLACE

• The requirements have now been extended to require the second best time as
well as the average time
• How might you design an algorithms to do so

You might also like