You are on page 1of 9

Contents

1. INTRODUCTION...............................................................................................................................................1
2. ALGORITHM.....................................................................................................................................................2
3. FLOW CHART...................................................................................................................................................3
4. HIERARCHY CHART:.........................................................................................................................................4
5. PSEUDO CODE.................................................................................................................................................5
6. Test Plan: Trace Table......................................................................................................................................6
7. CONCLUSION...................................................................................................................................................7

1. INTRODUCTION
The bellow given flowchart, hierarchy chart, pseudo code and algorithm
are of a billing system of a crop reservoir. The crop reservoir buys the
crops from the farmer in low rate and later they sell it for high rate to run
their business, Their pricing model is if the purchase of crops is up to 5 kg
then the rate is Rs 105 per kg, if the purchase of crops exceed 5 kg then
the rate is Rs 98 per kg up to 20 kg, if he crops exceed 20 kg then the
rate is Rs 94 per kg up to 50 kg, and if the purchase of crops is below 200
kg from then the rate is Rs 89 per kg. There is 10 % tax allotted by the
government in ever rate and there is 5% discount if the total amount
exceeds Rs 1500.
The given above descriptions are calculated below using algorithm, flow
chart, hierarchy chart, pseudo code and finally test plan to test the
calculation.

2. ALGORITHM
Step 1: start
Step 2: Declare the following variables with below mention purpose:
Unit=0: for the quantity of crop purchase in kg
amount=0: for amount after crop purchase
total_amt=0: for total amount after calculating 10% VAT)

1
dis_amt=0: for the discount amount allowed
net_amt=0: for total amount after allowing 5% discount (either
available or not)
choice: for user choice whether to repeat the program or not
Step 3: ask the unit of crop purchase
Step 4: if (unit>0 && unit<=5)
amount=105*unit
else if (unit>5 && unit<=20)
amount= (105*5) +(unit-5) *98
else if (unit>20 && unit<=50)
amount= (105*5) +(98*15) +(unit-20) *94
else if (unit>50 && unit<=200)
amount= (105*5) +(98*15) +(94*30) +(unit-150) *89
else, display (“invalid input”)
Step 5: display (amount is Rs”amount”)
Step5: calculate total amount adding 10% VAT
total_amt=amount*0.1+amount
Step6: if (total_amt>1500), calculate net amount with 5% discount
dis_amt=0.05*total_amt, display (discount amount is Rs”dis_amt”)
net_amt=total_amt – dis_amt
else, calculate net amount without discount
net_amt=total_amt
Step 7: Display (final net amount is Rs “net_amt”)
Step 8: ask user choice to repeat the program (y/n)
Step 9: if (choice==’y’ && choice==’Y’), go to step 3
Else, go to step 11
Step 11: End

2
3. FLOW CHART
Start

3
Set unit=0

Input unit purchase

True if(unit>0 False if(unit>5


Amount=unit*105 && &&
unit<=5) unit<=20)

Amount=105*5+(unit-5)*98 True
False
Amount= ( 1 0 5 * 5 )
+(98*15) +(unit-20)
True
*94

if(unit>20&
if(unit>50& False & unit<=50)
&
unit<=200)

True False
[Gra Display invalid input

Amount=(1 0 5 *5 )
+ (9 8 *1 5 )+ (9 4 *3
0)+ (uni t- 15 0 )

Total_amount= If Total True


Amount*0.1+Amount amount>1500
Calculate discount
and display
False
Net_amount= Total_amount

Net_amount= Total_amount -
0.05* Total_amount
Display Net amount

Ask user choice to repeat program(y/n)

True If (choice==’y’
AND choice==’Y’)

False
End
4
3
4. HIERARCHY CHART:

Main ()

Get unit of crop Calculate amount

Calculate total amount with


10% VAT

Calculate and display Calculate and display


net amount with discount net amount with 5% discount

5
5. PSEUDO CODE
Declare unit, rate, amount, total amount, dis amount, net amount as
variable
Set choice=y
Set unit, rate, total amount, dis amount, net amount=0
do
Ask user: “Enter the unit of crop:”
If unit is greater than 0 and less or equal to 5, then
amount= 105*unit
Else if, unit is greater than 5 and less or equal to 20, then
amount= (105*5) +(unit-5) *98
Else if, unit is greater than 20 and less or equal to 50, then
amount= (105*5) +(98*15) +(unit-20) *94
Else if, unit is greater than 50 and less or equal to 200, then
amount= (105*5) +(98*15) +(94*30) +(unit-150) *89
else
print ‘invalid input’
Endif
Print ‘amount’
total amount= amount+0.1*amount
print ‘total amount’
If total amount is greater than 1500, then
discount amount= 0.05*total mount
Print ‘discount amount’
net amount= total amount – discount amount
print ‘net amount’
Else, net amount= total amount
print ‘net amount’
Endif
Print ‘Do you want to repeat? (y/n)’
While (choice==’y’ and choice==’Y’)

6
6. Test Plan: Trace Table

Repeat Assumed unit of crop


5
Y 10
Y 35
Y 150
Y -5
N
Assumed (unit>0 (unit>5 (unit>20 (unit>50 Am output
unit of and and and and oun
crop unit<= unit<=2 unit<=5 unit<=20 t Total Total Invalid Net Net
5) 0) 0) 0) amou amount input(i amoun amount
nt >1500 ) t with without
dis dis

5 T 525 575.5 F 575.5


10 F T 101 1116. F 1116.5
5 5
35 F F T 340 37450 T 3558.2
5 5 3
150 F F F T 481 5296 T 5031.6
5 7
-5 F F F F i 0 0

7. CONCLUSION
In the above report we have shown the algorithm, flowchart, hierarchy
chart, pseudo code, trace table and finally shown the successful output.
The output is as per the need of the user. We have shown “invalid input” if
the user input wrong or invalid integer/character.

7
We have to come to know the concept of structural programming and
testing the program in code blocks compiler has given us great
opportunity to extend our knowledge and skills.

You might also like