Python Forum
How to calculate tax with a variable input and if else
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to calculate tax with a variable input and if else
#8
Why these huge changes and why all of a sudden only ten cents on a thaler?
You actually need smaller changes of your original program than the ones you made.
Also, there is nothing in the text stating the limits you introduced:
10000<= income <= 85528
and
-100 <= income<=1000
In fact the limit between tax and no tax is an income of 3089 thalers which corresponds to an annual income of exactly 556.02 thalers, but that is not in the assignment text (if you round it down to the nearest thaler, the limit is 3095, if you use the built-in round function, the limit is 3092). You can find it by very simple calculations, though.
I think you original program had the right grasp (with some of the corrections you introduced somewhat simplified):
income = float(input("Enter the annual income: "))
if income <= 85528:
    tax = income * 0.18 - 556.02
else:
    tax = (income - 85528) * 0.32 + 14839.02
tax = round(tax,0) # here you should make it never go negative
print("The tax is:", tax)
It is just the last part left (according to my comment): "If less than zero, make it zero"

Edit: Sorry, didn't notice at first that @shalinisamipillai was the author of the program that I commented on.
Reply


Messages In This Thread
RE: How to calculate tax with a variable input and if else - by Serafim - Feb-09-2021, 09:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] How to calculate tax with a variable input and if else rokemas 1 2,093 Dec-28-2020, 06:53 AM
Last Post: buran
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,465 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  How to make a dynamic variable based on input loltylerdowney 3 3,715 Nov-30-2017, 09:49 PM
Last Post: loltylerdowney

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020