In: Computer Science
Using tkinter, create a GUI interface which accepts input of annual income.
Using the table below, determine and output the income tax for that income. Tax Rate Income 10% $0 to $9,875.00; 12% $9,876.01 to $40,125.00; 22% $40,126 to $85,525.00; 24% $85,526.01 to $163,300.00.
Test with the following income data:
163,300.00
9,876.01
85,525.00
Sol.
from tkinter import *
class MyWindow:
def __init__(self, win):
self.lbl1=Label(win, text='Enter Your annual Income')
self.lbl3=Label(win, text='Tax')
self.t1=Entry(bd=3)
self.t3=Entry()
self.btn1 = Button(win, text='Tax')
self.lbl1.place(x=50, y=50)
self.t1.place(x=200, y=50)
self.b1=Button(win, text='Calculate Tax', command=self.tax)
self.b1.place(x=200, y=150)
self.lbl3.place(x=100, y=200)
self.t3.place(x=200, y=200)
def tax(self):
self.t3.delete(0, 'end')
num1=float(self.t1.get())
if(num1>0 and num1<=9875.00):
Tax=(num1*10)/100
if(num1>=9876.01 and num1<=40125.00):
Tax=(num1*12)/100
if(num1>=40126 and num1<=85525.00):
Tax=(num1*22)/100
if(num1>=85526.01 and num1<=163300.00):
Tax=(num1*24)/100
self.t3.insert(END, str(Tax))
window=Tk()
mywin=MyWindow(window)
window.title('Income Tax Calculator')
window.geometry("400x300+10+10")
window.mainloop()
Note: Please take close care of code indentation.