Professional Documents
Culture Documents
Problem Solving Practise Quest Answers-PSP
Problem Solving Practise Quest Answers-PSP
Problem Solving Practise Quest Answers-PSP
Q1)
a) IPO chart
Mult_table of 7
1. Set number=7
2. For i=1 to 10
Display result=i*number
End for
Input data
Number dataset
7
Expected result
result 1*7=7
2*7=14
3*7=21
4*7=28
5*7=35
6*7=41
7*7=49
8*7=56
9*7=63
10*7=70
Testing
Statement number count result output
no
1 7
2 1 7 1*7=7
3 2 14 2*7=14
4 3 21 3*7=21
4 28 4*7=28
3.2 5 35 5*7=35
6 41 6*7=41
7 49 7*7=49
8 56 8*7=56
9 63 9*7=63
10 70 10*7=70
Yes, the expected result for each set of data matches the calculated result.
Q2)
a) IPO chart
End while
Expected result
First dataset Second dataset
square 1 4
cube 1 8
Testing
Statement number Square cube
no
First pass
1,2 1
3 1
4 1
5 Output Output output
6 2
7 4
8 8
9 Output Output output
Yes, the expected result for each set of data matches the calculated result.
Q3)
a) IPO chart
b) CA table
Condition Action
Calculate_totalpayroll
1. Prompt operator for payroll_amt
2. Get payroll_amt
3. Set Total_payroll=0
4. repeat while payroll_amt not equal to 999
5. Total_payroll= Total_payroll+payroll_amt
6. Get payroll_amt
END while
7. Display total_payroll to the screen
q
d) Checking the algorithm
Input data
Input First Second
dataset dataset
payroll_amt 525 999
Expected result
First Second
dataset dataset
result 525 999
Testing
Statement Payroll_amt Total_payroll
no
First pass
1,2 525
3 0
4
5 525
6 200
7 725
8 999
9 725
10 output
Yes, the expected result for each set of data matches the calculated result.
Q5)
IPO chart
CA table
Condition Action
If hour<12 Format=”AM”
If hour=12 Format=”AM”
If hour>12 Hour=hour-12
Format=”PM”
Convert_timeformat
1. Prompt operator for hour, minute
2. Get hour,minute
3. Repeat While hour=!99 and minute=!99
a. If hour<12
Format=”AM”
b. Else if hour=12
Format=”AM”
c. Else if hour>12
Hour=hour-12
Format=”PM”
End while
Input data
Input First dataset Second dataset
hour 13 10
minute 10 00
Expected result
First dataset Second dataset
hour 01 10
minute 10 00
Format PM AM
Testing
Statement hour minute format
no
First pass
1,2 13 10
3
3a
3b
3c 01 10 PM
4 output Output Output
Second pass
1,2 10 00
3
3a 10 00 AM
4 output Output Output
Yes, the expected result for each set of data matches the calculated result.