In [ ]:
from IPython.display import clear_output
from time import asctime

def calculatepay():
    
    firstname = input("Enter your first name")
    lastname = input ("Enter your last name")
    payRate = float(input ("Input your hourly wage"))
    hours = float(input("Input Hours worked"))

    fedTaxRate = .101 #federal taxe rates or about 10.1%
    stateTaxRate = .0447 #state taxes of CT which are about 4.47%
    socialSecurity = .153 #how much we put in Medicare and Social Security 15.3% of your income going bye
    insurance = 119.00 #how much you pay into insurance to insure your items, about $119.00

    #I believe this next line of code is about overtime pay and not about normal pay which is just Hourly Wage * Hours Worked - Taxes/Social Security/Insurance.
    #This code works by if hours are greater than 40 it will subtract hours by 40 to get timetime and then it will do the pay times 1.5 times over time hours then it finally does the pay you would normally start with and add it by overtime.
    if hours > 40.00:
        basePay = payRate * 40
        overHours = hours - 40 
        overtime = (payRate * 1.5) * overHours 
        grossPay = basePay + overtime
        grossPayMessage = ("You workd 40 hours and {} hours overtime for a total amount of ${}".format(overHours, grossPay))
       #this code is if the hours are 40 and below and this calculates the pay times hours and puts overtime to 0.  
    else:
        grossPay = payRate * hours
        overtime = 0.0
        grossPayMessage = ("You worked {} hours for a total of ${}".format(hours, grossPay))

    #this code gets the numbers for the social-security, Fed and Local taxes and then puts them in total deductions before subtracting that from the pay.
    socialSecurityPaid = grossPay * socialSecurity
    fedTaxPaid = grossPay * fedTaxRate
    stateTaxPaid = grossPay * stateTaxRate

    totalDeductions = fedTaxPaid + insurance + socialSecurityPaid + stateTaxPaid
 

    truePay = grossPay - totalDeductions

        

######################################################################################################

    invoicePage = open("{}-{}".format(lastname, firstname),"w") #names the personnel file you get

    invoicePage.write("\n") #Break Line
    invoicePage.write("pay for {} {}".format(firstname, lastname)) #The pay you get
    invoicePage.write("\n") #Break Line
    invoicePage.write("total hours worked is {}".format(hours)) #The amount of hours you worked
    invoicePage.write("\n") #Break Line
    invoicePage.write(grossPayMessage) #Gross Payment before taxes
    invoicePage.write("\n") #Break Line
    invoicePage.write("Date/time of this report was {}".format(asctime())) #The time when the calculator calculated
    invoicePage.write("\n") # Break Line
    invoicePage.write(grossPayMessage) #Gross Pay
    invoicePage.write("\n") #Break Line
    invoicePage.write("Deductions/n") #The amount you loose into total
    invoicePage.write("--------------------------------------------") #Loooooooooooooong line of code that just does "--------------------------------"
    invoicePage.write("The amount payed into Social Security is {}".format(socialSecurityPaid)) #The amount you pay into Social Security
    invoicePage.write("\n")
    invoicePage.write("Federal Income Tax is {}".format(fedTaxPaid)) #The amount of money you put into Federal Taxes
    invoicePage.write("\n")
    invoicePage.write("State Income Tax is {}".format(stateTaxPaid)) #The amount of money you put into State Taxes
    invoicePage.write("\n")
    invoicePage.write("Insurance payment is {}".format(insurance)) #The amount you put into a company that will give you money or rebuild your home
    invoicePage.write("\n")
    invoicePage.write("totalDeductions are {}".format(totalDeductions)) #All of the deductions combined
    invoicePage.write("\n")
    invoicePage.write("-------------------------------------------")
    invoicePage.write("\n")
    invoicePage.write("You made {} before deductables were added".format(grossPay)) #Before Taxes
    invoicePage.write("\n")
    invoicePage.write("You made {} after deductables were added".format(truePay)) #After Taxes
    
    invoicePage.close() #Close the clode
    
    invoiceView = open("{}-{}".format(lastname, firstname),"r")
    dataToRead = invoiceView.read()
    print(dataToRead)

    invoicePage.close()

 
    print("I will calculate your pay with this calculator")
    input()

def menu():


    while True:
        print("Welcome to the pay calculator")
        print("What do you want to do?")
        print("put in 1 for calculating pay. I calculate pay after all")
        print("Put in 2 if you want to exit")

        menuChoose = input("1 or 2")

        if menuChoose == "1":
            calculatepay()
        elif menuChoose == "2":
            print("Have a good day")
            break

        else:
            print("Invalid choose, choose 1 or 2")
            input("Press enter")
            clear_output()

if __name__ == "__main__":
    menu()
Welcome to the pay calculator
What do you want to do?
put in 1 for calculating pay. I calculate pay after all
Put in 2 if you want to exit
In [ ]: