You are on page 1of 14

Lesson -1

C++
Lesson Objectives

 How to write Instruction, Condition, Statement and


execute them for different programming logics
 Develop the correct logic for the problem
Task 1.1

 Write down the set of instructions required to wash


clothes in an automatic washing machine.
Task 1.2

 Write a sequence of instructions to make a cup of


tea.
 Start with the instruction FILL KETTLE, end with
DRINK TEA and allow for options to add milk and
sugar.
Task 1.3

 Write a set of instructions to write and post a letter.


 Start with WRITE LETTER, end with PLACE LETTER IN
POST BOX and allow for the choice of sending by
first or second class post.
Task 1.4

 Write a set of instructions to pay for items bought in


a large store in which you have an account.
 Allow options to pay by cash, credit card, cheque or
through your account.
 Start with FIND OUT TOTAL COST, end with TAKE
PURCHASES.
 You should include statements such as HANDOVER
CREDIT CARD, SIGN AUTHORISATION SLIP, GIVE
ACCOUNT NUMBER4, TAKE CHANGE and SHOW
CHEQUE CARD.
TASK 1.5

 Write the expression for the conditions required in


order for a laser printer to produce output.
 It will be necessary for the printer to be ONLINE and
the TONER SHOULD NOT BE EMPTY.
 There must ALSO BE PAPER in the MAIN TRAY or in
the AUXILIARY TRAY.
Task 1.6

 Write a set of instructions to list the names of those


students which achieved a score of less than 50% in
an exam. There are exactly 20 students in the class
 Your solution should contain the statements:
 READ MARK AND NAME
 ADD NAME TO LIST OF FAILS
 IF mark is less than 50% THEN
Task 1.7

 Write instructions to look through the articles in a


magazine until one written by LIZ HERRON is found.
 Your solution should contain the instructions
 FIND START OF ARTICLE
 READ THE AUTHOR’S NAME
Task 1.8

 A game involves throwing two dice. If the two values


thrown are not the same, then the dice showing the
lower value must be rolled again as often as is
necessary until both dice show the same value.
 Write a set of instructions to perform this game.
 Your solution should contain the statements:
 ROLL BOTH DICE
 AND CHOOSE DICE WITH LOWER VALUE
Task 1.9

 List the name of five data items an car insurance


company use and give a possible value for each.
1.10

 Identify other input, calculation and output


statements in the insurance premium example
above.
Task 1.11
 An orders clerk for a mail order company takes orders
over the telephone.
 Customers begin by stating the numbers of different
items they wish to purchase.
 For each item the clerk requests the catalogue
number, which if given incorrectly, will require to be
restated (it is possible that an invalid number will be
given several times before the customer finally gives
a recognised value).
 The clerk also asks the quantity required before
checking if the item is in stock.
 If the item is out of stock or there is insufficient
quantity, the clerk will offer an alternative if one is
available.
 The clerk adds available items to an order list once
the call is complete, the order list is sent to the
dispatch department.
Task 1.11 (continue)
 A possible Level 1 solution to this task is:
 Get number of items
 For each item DO
 Get order details
 Process item
 ENDFOR
 Send order to dispatches department
Write a level 2 solution which should include statements
such as:
IF item in stock AND sufficient quantity THEN
WHILE catalogue number is invalid DO
Check for alternative
IF alternative acceptable THEN

You might also like