Student no.
:0726860 Documentation CP4012
st
Name: Altafhusain Khan Msc. Computer Science(1 Semister)
Week 3 - Application 2 – PSEUDOCODE (Video Shop Cash Register)
On the click event of “Calculate” Command Button
Begin
Declaring Doubles amtWhol, amtDue, amtTaken, changeDue
Declaring String amtDeciS, amtDeci, amtWholeS
Read value of txtAmtDue.Text into amtDue
Read value of txtAmtTaken.Text amtTaken
Read into changeDue Subtract value of amtDue from amtTaken
Read value of changeDue into label1.Text
Read value of changeDue into label2.Text
Add an extra line at the end of Label1.Text
Change format to currency of changeDue
Read value of changeDue into lblChangeDue.Text
Read value of changeDue into amtDeciS with CURRENCY format
Read 2 characters from right of Label2.Text into amtDeci
Read value of changeDue into amtWholeS with CURRENCY format
Read last character of round amount of amtWholeS into amtWhol
'""""""""""""""""Function for whole amount"""""""""""""
Declare Double wholeAmtNo1, wholeAmtNo2
Declare String totStrNo
Declare Boolean rtnFunction
Declare Integer i
Initialise totStrNo with empty value
Set rtnFunction to False
set rtnFunction to true if changeDue has decimal values by
calling function findDecimal
If value of rtnFunction is True then
For I = 1 to length of changeDue
If I encounters value “.” Then
STOP
End If
Read ith value from left of changeDue to totStrNo
Next
Else
Read value of changeDue into totStrNo
End If
Read into wholeAmtNo1 subtract value
Read into wholeAmtNo1 Subtracted value of amtWhol from totStrNo
Read value of amtWhol into wholeAmtNo2
Call procedure CalcAmountChangeNote pass the value of wholeAmtNo1
Call procedure CalcAmountChangeCoin pass the value of wholeAmtNo2,”c”
If value of rtnFunction is True Then
Declare Integers no1, no2, totNo, modval, dvdval
1/5
Student no.:0726860 Documentation CP4012
st
Name: Altafhusain Khan Msc. Computer Science(1 Semister)
Subtract right 1st value of amtDeciS from amtDeci value, read into
no1
read into no2 right 1st value of amtDeciS
If no1 is not zero Then
Do While until no1 not zero
Initialise totNo with 0
Initialise modval with 0
Initialise dvdval with 0
If no1 is greater than equals to 50 Then
Read remainder of no1 by 50 into modval
Read quotient of no1 by 50 into dvdval
Add values of Label1.Text & new line & value of dvdval
& "*50p" into Label1.Text
Read value of modval into no1
ElseIf no1 greater than equals to 20 Then
Read remainder of no1 by 20 into modval
Read quotient of no1 by 20 into dvdval
Add values of Label1.Text & new line & value of dvdval
& "*20p" into Label1.Text
Read value of modval into no1
ElseIf no1 greater than equals to 10 Then
Read remainder of no1 by 10 into modval
Read quotient of no1 by 10 into dvdval
Add values of Label1.Text & new line & value of dvdval
& "*10p" into Label1.Text
Read value of modval into no1
End If
Loop
End If
If no2 is not zero Then
Call function CalcAmountChangeCoin passing values no2,”p”
End If
End If
End
When procedure CalcAmountChangeNote called (Parameter n1 integer)
Begin
Declare Integers no1, totNo, modval, dvdval
Read value of n1 into no1
Do while until no1 is not 0
Initialise totNo with 0
Initialise modval with 0
Initialise dvdval with 0
If no1 is greater than equals to 20 Then
Read remainder of no1 by 20 into modval
Read quotient of no1 by 20 into dvdval
Add values of Label1.Text & new line & value of dvdval
& "* £20 Note" into Label1.Text
Read value of modval into no1
ElseIf no1 is greater than equals to 10 Then
Read remainder of no1 by 10 into modval
2/5
Student no.:0726860 Documentation CP4012
st
Name: Altafhusain Khan Msc. Computer Science(1 Semister)
Read quotient of no1 by 10 into dvdval
Add values of Label1.Text & new line & value of dvdval
& "* £10 Note" into Label1.Text
Read value of modval into no1
End If
Loop
End
When procedure CalcAmountChangeCoin called (Parameters n1 integer, amtPense
String)
Begin
Declare Integers no2, totNo, modval, dvdval
Read value of n2 in no2
Do While until no2 is not 0
Initialise totNo with 0
Initialise modval with 0
Initialise dvdval with 0
If no2 is greater than equals to 5 Then
Read remainder of no2 by 5 into modval
Read quotient of no2 by 5 into dvdval
If amtPense is "p" Then
Add values of Label1.Text & new line & value of dvdval
& "* 5p" into Label1.Text
Else
Add values of Label1.Text & new line & value of dvdval
& "* £5 Note" into Label1.Text
End If
Read value of modval into no2
ElseIf no2 is greater than equals to 2 Then
Read remainder of no2 by 2 into modval
Read quotient of no2 by 2 into dvdval
If amtPense is "p" Then
Add values of Label1.Text & new line & value of dvdval
& "* 2p" into Label1.Text
Else
Add values of Label1.Text & new line & value of dvdval
& "* £2 Coin" into Label1.Text
End If
Read value of modval into no2
ElseIf no2 is greater than equals to 1 Then
Read remainder of no2 by 1 into modval
Read quotient of no2 by 1 into dvdval
If amtPense is "p" Then
Add values of Label1.Text & new line & value of dvdval
& "* 1p" into Label1.Text
Else
Add values of Label1.Text & new line & value of dvdval
& "* £1 Coin" into Label1.Text
End If
Read value of modval into no2
End If
Loop
End
3/5
Student no.:0726860 Documentation CP4012
st
Name: Altafhusain Khan Msc. Computer Science(1 Semister)
When function findDecimal called Parameters(String n1) returns Boolean value
Begin
Declare Integer i
For I = 1 to lenth of n1
If n1 contains “.” Then
Set value of findDecimal to True
Stop
End If
Next
End
On click event of “Clear” Command Button
Begin
Empty txtAmtDue.Text
Empty txtAmtTaken.Text
Empty Label1.Text
Empty Label2.Text
Empty lblChangeDue.Text
Set Cursor in txtAmtDue
End
Forms Designing and Controls Size, Tab Index
Vidoshop Cash Register System
Amount Due Tab Index 0
Amount tendered Tab Index 1
Change Due
Calculate Clear Quit
Tab Index 2 Tab Index 3 Tab Index 4
Controls used for the design are:
Label controls, Text Box controls, Command button controls
Size of Label controls is = 79 (Width), 13 (Height)
Size of Text Box controls is = 100 (Width), 20 (Height)
Size of Command Button controls = (Width, Height)
4/5
Student no.:0726860 Documentation CP4012
st
Name: Altafhusain Khan Msc. Computer Science(1 Semister)
Calculate = (75, 23)
Clear = (75, 23)
Quit = (75, 23)
Assumptions:
- Input validation should be made on each input controls
- Error handling should be done
Test Data for the program:
amount Due = £55.78
amount tendered = £79
change Due = £23.22
result:
1*£20 Note
1*£2 coin
1*£1 coin
1*20p
1*2p
Evaluation:
- The program does fulfill the purpose accurately.
- The program is completely error free.
- Final product is completely reliable.
- The program is fully documented.
- The code written for the program can be more compressed by defining
functions.
- The program is not secured, security aspects have not been considered
yet.
- Error handling and Input validations has to be considered.
5/5