You are on page 1of 4

PROGRAM DESCRIPTION:

Python program to find the tax amount for the given case.After converting by taking
the tax amount as the input,find the sum of the digits and convert it
into an integer.Then perform heap permutation by passing the interger found along
with the number one lesser than the integer and one greater than the
integer as the input.
INPUT:
Test Case(1): 2000000
Test Case(2): 637000
Test Case(3): 9843000
Test Case(4): 784000

min1=150001
max1=300000
rate1=0.10
min2=300002
max2=500000
rate2=0.20
min3=500001
rate3=0.30
income=int(input("enter the income:"))
tax_income = income+150000
if(tax_income<=0):
print("no tax")
elif(tax_income>=max1 and tax_income<max1):
tax=(tax_income-min1)*rate1
elif(tax_income>=min2 and tax_income<max2):
tax=(tax_income-min2)*rate2
else:
tax=(tax_income+min3)-rate3
print("TAX=",tax)
sum = 0
while tax>=1 :
temp=tax%10
sum += temp
tax=int(tax/10)
print(sum)
print((sum))
def heapPermutation(a,size):
if size==1:
print(a)
return
for i in range(size):
heapPermutation(a,size+1)
if size and 1:
a[0],a[size-1]=a[size+1],a[0]
else:
a[1],a[size-1]=a[size+1],a[i]
a=[int(sum)-1,int(sum),int(sum)+1]
n=len(a)
heapPermutation(a,n-1)
ERRORS:

Line #10:
tax_income = income+150000 (LOGICAL ERROR)
Line #13:
elif(tax_income>=max1 and tax_income<max1): (LOGICAL ERROR)
Line #18:
tax=(tax_income+min3)-rate3 (LOGICAL ERROR)
Line #26:
print((sum)) (LOGICAL ERROR)
Line #32:
heapPermutation(a,size+1) (RECURSION ERROR)
Line #33:
if size and 1:
a[0],a[size-1]=a[size+1],a[0]
else:
a[1],a[size-1]=a[size+1],a[i] (INDEX ERROR)
Line #39: heappermutation(a,n-1) (NAME AND LOGICAL ERROR)

CORRECT CODE:-

min1=150001
max1=300000
rate1=0.10
min2=300002
max2=500000
rate2=0.20
min3=500001
rate3=0.30
income=int(input("enter the income:"))
tax_income = income-150000
if(tax_income<=0):
print("no tax")
elif(tax_income>=min1 and tax_income<max1):
tax=(tax_income-min1)*rate1
elif(tax_income>=min2 and tax_income<max2):
tax=(tax_income-min2)*rate2
else:
tax=(tax_income-min3)*rate3
print("TAX=",tax)
sum = 0
while tax>=1 :
temp=tax%10
sum += temp
tax=int(tax/10)
print(sum)
print(int(sum))
def heapPermutation(a,size):
if size==1:
print(a)
return
for i in range(size):
heapPermutation(a,size-1)
if size and 1:
a[0],a[size-1]=a[size-1],a[0]
else:
a[1],a[size-1]=a[size-1],a[i]
a=[int(sum)-1,int(sum),int(sum)+1]
n=len(a)
heapPermutation(a,n)
OUTPUT:

Test Case(1):
enter the income:2000000

TAX= 404999.7

35.70000000001164

35

[34, 35, 36]

[35, 34, 36]

[36, 35, 34]

[35, 36, 34]

[34, 35, 36]

[35, 34, 36]

Test Case(2):
enter the income:637000

TAX= 37399.6

31.599999999998545

31

[30, 31, 32]

[31, 30, 32]

[32, 31, 30]

[31, 32, 30]

[30, 31, 32]

[31, 30, 32]

Test Case(3):
enter the income:9843000

TAX= 2757899.6999999997

47.6999999997206

47
[46, 47, 48]
[47, 46, 48]

[48, 47, 46]

[47, 48, 46]

[46, 47, 48]

[47, 46, 48]

Test Case(4):
enter the income:784000

TAX= 40199.7

23.69999999999709

23

[22, 23, 24]

[23, 22, 24]

[24, 23, 22]

[23, 24, 22]

[22, 23, 24]

[23, 22, 24]

You might also like