In: Computer Science
In python. Write a code that get salaries of people and their respective federal and state tax percentages. Then the code should calculate the net salary using the formula below and show it to the user. After that it should ask if the user want to continue the program or not, and should continue working as long as the user enters y, Y, yes or Yes.
Continue="y" #intialize continue variable to y for first execution in while loop
while Continue.lower() =="y" or Continue.lower()=="yes":
Salary=float(input("Enter your Salary: "))
if Salary<1: #if salary is negative ,it will print invalid input
print("Invalid Input")
else:
Federal_Tax_per = int(input("Enter your Federal Tax percentage without % symbol: "))
State_Tax_per = int(input("Enter your State Tax percentage without % symbol: "))
#calculation of Federal and state Tax given by given by user
Federal_Tax = Salary*Federal_Tax_per/100
State_Tax = Salary*State_Tax_per/100
#calculation of Net Salary
Net_salary = Salary - Federal_Tax - State_Tax #
print("The Net salary for your entered Income: {:.2f}".format(Net_salary)) #We used format method for two decimal Net salary
print("")
Continue=input("If you want to continue, Type 'y' or 'Y' or 'yes' or 'Yes' and enter. ")
OUTPUT: