SlideShare a Scribd company logo
1 of 8
Download to read offline
from datetime import datetime
def CreateUsers():
print('##### Create users, passwords, and roles #####')
with open('user.txt', 'a') as UserFile:
while True:
username = GetUserName()
if username.upper() == "END":
break
userpwd = GetUserPassword()
userrole = GetUserRole()
UserDetail = username + "|" + userpwd + "|" + userrole + "n"
UserFile.write(UserDetail)
UserFile.close()
printuserinfo()
def GetUserName():
username = input("Enter username or END to Quit: ")
return username
def GetUserPassword():
userpwd = input("Enter pwd: ")
return userpwd
def GetUserRole():
while True:
userrole = input("Enter role (Admin or User): ")
if userrole == "Admin" or userrole == "User":
return userrole
else:
print('Please input a valid userrole (Admin or User).')
def printuserinfo():
UserFile = open("user.txt","r")
while True:
UserDetail = UserFile.readline()
if not UserDetail:
break
UserDetail = UserDetail.replace("n", "")
UserList = UserDetail.split("|")
username = UserList[0]
userpassword = UserList[1]
userrole = UserList[2]
print("User Name: ", username, " Password: ", userpassword, " Role: ", userrole)
def Login():
with open('User.txt', 'r') as UserList:
while True:
UserDetail = UserFile.readline()
if not UserDetail:
return "None", "None"
UserDetail = UserDetail.replace("n", "")
UserList = UserDetail.split("|")
UserName = input("Enter User Name: ")
if UserName == UserList[0]:
UserRole = UserList[2]
return UserRole, UserName
def GetEmpName():
empname = input("Enter employee name: ")
return empname
def GetDatesWorked():
fromdate = input("Enter Start Date (mm/dd/yyyy: ")
todate = input("Enter End Date (mm/dd/yyyy")
def GetHoursWorked():
hours = float(input('Enter amount of hours worked: '))
return hours
def GetHourlyRate():
hourlyrate = float(input ("Enter hourly rate: "))
return hourlyrate
def GetTaxRate():
taxrate = float(input ("Enter tax rate: "))
return taxrate
def CalcTaxAndNetPay(hours, hourlyrate, taxrate):
grosspay = hours * hourlyrate
incometax = grosspay * taxrate
netpay = grosspay - incometax
return grosspay, incometax, netpay
def printinfo(DetailsPrinted):
TotEmployees = 0
TotHours = 0.00
TotGrossPay = 0.00
TotTax = 0.00
TotNetPay = 0.00
EmpFile = open("Employees.txt","r")
while True:
rundate = input ("Enter start date for report (MM/DD/YYYY) or All for all data in file: ")
if (rundate.upper() == "ALL"):
break
try:
rundate = datetime.strptime(rundate, "%m/%d/%Y")
break
except ValueError:
print("Invalid date format. Try again.")
print()
continue # skip next if statement and re-start loop
while True:
EmpDetail = EmpFile.readline()
if not EmpDetail:
break
EmpDetail = EmpDetail.replace("n", "") #remove carriage return from end of line
EmpList = EmpDetail.split("|")
fromdate = EmpList[0]
if (str(rundate).upper() != "ALL"):
checkdate = datetime.strptime(fromdate, "%m/%d/%Y")
if (checkdate < rundate):
continue
todate = EmpList[1]
empname = EmpList[2]
hours = float(EmpList[3])
hourlyrate = float(EmpList[4])
taxrate = float(EmpList[5])
grosspay, incometax, netpay = CalcTaxAndNetPay(hours, hourlyrate, taxrate)
print(fromdate, todate, empname, f"{hours:,.2f}", f"{hourlyrate:,.2f}", f"{grosspay:,.2f}",
f"{taxrate:,.1%}", f"{incometax:,.2f}", f"{netpay:,.2f}")
TotEmployees += 1
TotHours += hours
TotGrossPay += grosspay
TotTax += incometax
TotNetPay += netpay
EmpTotals["TotEmp"] = TotEmployees
EmpTotals["TotHrs"] = TotHours
EmpTotals["TotGrossPay"] = TotGrossPay
EmpTotals["TotTax"] = TotTax
EmpTotals["TotNetPay"] = TotNetPay
DetailsPrinted = True
if (DetailsPrinted): #skip of no detail lines printed
PrintTotals (EmpTotals)
else:
print("No detail information to print")
def PrintTotals(EmpTotals):
print()
print(f'Total Number Of Employees: {EmpTotals["TotEmp"]}')
print(f'Total Hours Worked: {EmpTotals["TotHrs"]:,.2f}')
print(f'Total Gross Pay: {EmpTotals["TotGrossPay"]:,.2f}')
print(f'Total Income Tax: {EmpTotals["TotTax"]:,.2f}')
print(f'Total Net Pay: {EmpTotals["TotNetPay"]:,.2f}')
if __name__ == "__main__":
##################################################
########## Write the line of code to call the method CreateUsers
def function_CreateUsers():
print()
print("##### Data Entry #####")
########## Write the line of code to assign UserRole and UserName to the function Login##
def Login(GetUserRole, UserName):
DetailsPrinted = False ###
EmpTotals = {} ###
########## Write the if statement that will check to see if UserRole is equal to NONE (NOTE:
code will show red error lines until this line is written)####
if GetUserRole == 'NONE':
print(UserName," is invalid.")
else:
# only admin users can enter data
##### write the if statement that will check to see if the UserRole is equal to ADMIN (NOTE:
code will show red error lines until this line is written)
if GetUserRole == 'ADMIN':
EmpFile = open("Employees.txt", "a+")
while True:
empname = GetEmpName()
if (empname.upper() == "END"):
break
fromdate, todate = GetDatesWorked()
hours = GetHoursWorked()
hourlyrate = GetHourlyRate()
taxrate = GetTaxRate()
EmpDetail = fromdate + "|" + todate + "|" + empname + "|" + str(hours) + "|" + str(hourlyrate) +
"|" + str(taxrate) + "n"
EmpFile.write(EmpDetail)
# close file to save data
EmpFile.close()
printinfo(DetailsPrinted)
Question:
I can't get the 2nd part of the program to display. The 1st part of the program works fine. The 2ns
art of the program starts at def GetEmpName(): The second part asks for employee names,
start/end dates, hours, hourly rate, tax rate, gross pay, and net pay. Ty

More Related Content

Similar to from datetime import datetime def CreateUsers()- print('##### Crea.pdf

The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfRahul04August
 
include ltstdiohgt include ltstringhgt define M.pdf
include ltstdiohgt include ltstringhgt define M.pdfinclude ltstdiohgt include ltstringhgt define M.pdf
include ltstdiohgt include ltstringhgt define M.pdfadisainternational
 
Classes(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docxClasses(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docxbrownliecarmella
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfseoagam1
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handoutsjhe04
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfrajkumarm401
 
I got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdfI got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdfshreeaadithyaacellso
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaYashKoli22
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODESYashKoli22
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE YashKoli22
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
Below is a Password Management Program incl.pdf
Below is a Password Management Program                 incl.pdfBelow is a Password Management Program                 incl.pdf
Below is a Password Management Program incl.pdfabiagencymadurai
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2Warui Maina
 
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxUser.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxdickonsondorris
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2Mohamed Ahmed
 
#include iostream #include string #include invalidHr.h.pdf
 #include iostream #include string #include invalidHr.h.pdf #include iostream #include string #include invalidHr.h.pdf
#include iostream #include string #include invalidHr.h.pdfAPMRETAIL
 
Multi client
Multi clientMulti client
Multi clientganteng8
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfadianantsolutions
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoThe Software House
 

Similar to from datetime import datetime def CreateUsers()- print('##### Crea.pdf (20)

The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
include ltstdiohgt include ltstringhgt define M.pdf
include ltstdiohgt include ltstringhgt define M.pdfinclude ltstdiohgt include ltstringhgt define M.pdf
include ltstdiohgt include ltstringhgt define M.pdf
 
Classes(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docxClasses(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docx
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdf
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
I got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdfI got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdf
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bca
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODES
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
Below is a Password Management Program incl.pdf
Below is a Password Management Program                 incl.pdfBelow is a Password Management Program                 incl.pdf
Below is a Password Management Program incl.pdf
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxUser.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
Presentation for structure in c
Presentation for  structure in cPresentation for  structure in c
Presentation for structure in c
 
#include iostream #include string #include invalidHr.h.pdf
 #include iostream #include string #include invalidHr.h.pdf #include iostream #include string #include invalidHr.h.pdf
#include iostream #include string #include invalidHr.h.pdf
 
Multi client
Multi clientMulti client
Multi client
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
 

More from atozworkwear

g- - 10 h- 757- 10 i- AB12- 10.pdf
g- - 10 h- 757- 10 i- AB12- 10.pdfg- - 10 h- 757- 10 i- AB12- 10.pdf
g- - 10 h- 757- 10 i- AB12- 10.pdfatozworkwear
 
From the Extensible Authentication Protocol (EAP) methods given below-.pdf
From the Extensible Authentication Protocol (EAP) methods given below-.pdfFrom the Extensible Authentication Protocol (EAP) methods given below-.pdf
From the Extensible Authentication Protocol (EAP) methods given below-.pdfatozworkwear
 
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdf
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdffyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdf
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdfatozworkwear
 
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdf
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdfFour people are running for class president- Liz- Fred- Sue- and Tom-.pdf
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdfatozworkwear
 
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdf
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdfGalen-Pelated Transactions The debits and crests for thiee redated tra.pdf
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdfatozworkwear
 
Gabriel and Lucia took a road trip across the country- The room costs-.pdf
Gabriel and Lucia took a road trip across the country- The room costs-.pdfGabriel and Lucia took a road trip across the country- The room costs-.pdf
Gabriel and Lucia took a road trip across the country- The room costs-.pdfatozworkwear
 
GAAP- generally accepted accounting principles are based on 4 principl.pdf
GAAP- generally accepted accounting principles are based on 4 principl.pdfGAAP- generally accepted accounting principles are based on 4 principl.pdf
GAAP- generally accepted accounting principles are based on 4 principl.pdfatozworkwear
 
From the deepest to most superficial- name and describe the five strat.pdf
From the deepest to most superficial- name and describe the five strat.pdfFrom the deepest to most superficial- name and describe the five strat.pdf
From the deepest to most superficial- name and describe the five strat.pdfatozworkwear
 
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdf
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdffX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdf
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdfatozworkwear
 
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdf
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdfFuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdf
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdfatozworkwear
 
Fraudulent financlat reporting and misappropriation of assets differ i.pdf
Fraudulent financlat reporting and misappropriation of assets differ i.pdfFraudulent financlat reporting and misappropriation of assets differ i.pdf
Fraudulent financlat reporting and misappropriation of assets differ i.pdfatozworkwear
 
Funtime plc- who manufacture games has the following clauses in its Ar.pdf
Funtime plc- who manufacture games has the following clauses in its Ar.pdfFuntime plc- who manufacture games has the following clauses in its Ar.pdf
Funtime plc- who manufacture games has the following clauses in its Ar.pdfatozworkwear
 
From the highest and lowest elevations that your found for the USGS 7-.pdf
From the highest and lowest elevations that your found for the USGS 7-.pdfFrom the highest and lowest elevations that your found for the USGS 7-.pdf
From the highest and lowest elevations that your found for the USGS 7-.pdfatozworkwear
 
From the limited information you have in the ('Managing Up (B)- Jada'.pdf
From the limited information you have in the  ('Managing Up (B)- Jada'.pdfFrom the limited information you have in the  ('Managing Up (B)- Jada'.pdf
From the limited information you have in the ('Managing Up (B)- Jada'.pdfatozworkwear
 
From the book- A Short Course in Cloud Physics An air sample contains.pdf
From the book- A Short Course in Cloud Physics  An air sample contains.pdfFrom the book- A Short Course in Cloud Physics  An air sample contains.pdf
From the book- A Short Course in Cloud Physics An air sample contains.pdfatozworkwear
 
From January through December 2012- Gallup interviewed more than 170-0.pdf
From January through December 2012- Gallup interviewed more than 170-0.pdfFrom January through December 2012- Gallup interviewed more than 170-0.pdf
From January through December 2012- Gallup interviewed more than 170-0.pdfatozworkwear
 
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdf
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdfFrenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdf
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdfatozworkwear
 
Freelance reporter Irwin Fletcher is examining the historical voting r.pdf
Freelance reporter Irwin Fletcher is examining the historical voting r.pdfFreelance reporter Irwin Fletcher is examining the historical voting r.pdf
Freelance reporter Irwin Fletcher is examining the historical voting r.pdfatozworkwear
 
Forum Description- Include your sources- 1- The two divisions of the.pdf
Forum Description- Include your sources-  1- The two divisions of the.pdfForum Description- Include your sources-  1- The two divisions of the.pdf
Forum Description- Include your sources- 1- The two divisions of the.pdfatozworkwear
 

More from atozworkwear (20)

g- - 10 h- 757- 10 i- AB12- 10.pdf
g- - 10 h- 757- 10 i- AB12- 10.pdfg- - 10 h- 757- 10 i- AB12- 10.pdf
g- - 10 h- 757- 10 i- AB12- 10.pdf
 
From the Extensible Authentication Protocol (EAP) methods given below-.pdf
From the Extensible Authentication Protocol (EAP) methods given below-.pdfFrom the Extensible Authentication Protocol (EAP) methods given below-.pdf
From the Extensible Authentication Protocol (EAP) methods given below-.pdf
 
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdf
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdffyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdf
fyuten integraines- Stitetion comnitite- Atrering comenites- Project t.pdf
 
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdf
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdfFour people are running for class president- Liz- Fred- Sue- and Tom-.pdf
Four people are running for class president- Liz- Fred- Sue- and Tom-.pdf
 
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdf
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdfGalen-Pelated Transactions The debits and crests for thiee redated tra.pdf
Galen-Pelated Transactions The debits and crests for thiee redated tra.pdf
 
Gabriel and Lucia took a road trip across the country- The room costs-.pdf
Gabriel and Lucia took a road trip across the country- The room costs-.pdfGabriel and Lucia took a road trip across the country- The room costs-.pdf
Gabriel and Lucia took a road trip across the country- The room costs-.pdf
 
GAAP- generally accepted accounting principles are based on 4 principl.pdf
GAAP- generally accepted accounting principles are based on 4 principl.pdfGAAP- generally accepted accounting principles are based on 4 principl.pdf
GAAP- generally accepted accounting principles are based on 4 principl.pdf
 
From the deepest to most superficial- name and describe the five strat.pdf
From the deepest to most superficial- name and describe the five strat.pdfFrom the deepest to most superficial- name and describe the five strat.pdf
From the deepest to most superficial- name and describe the five strat.pdf
 
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdf
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdffX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdf
fX(x)-x2e1-x-x-0-Y-cX- Find fY(y)-.pdf
 
G-SaSabSbaa.pdf
G-SaSabSbaa.pdfG-SaSabSbaa.pdf
G-SaSabSbaa.pdf
 
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdf
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdfFuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdf
Fuzzy Monkey Technologies- Incorporated purchased as a long-term inves.pdf
 
Fraudulent financlat reporting and misappropriation of assets differ i.pdf
Fraudulent financlat reporting and misappropriation of assets differ i.pdfFraudulent financlat reporting and misappropriation of assets differ i.pdf
Fraudulent financlat reporting and misappropriation of assets differ i.pdf
 
Funtime plc- who manufacture games has the following clauses in its Ar.pdf
Funtime plc- who manufacture games has the following clauses in its Ar.pdfFuntime plc- who manufacture games has the following clauses in its Ar.pdf
Funtime plc- who manufacture games has the following clauses in its Ar.pdf
 
From the highest and lowest elevations that your found for the USGS 7-.pdf
From the highest and lowest elevations that your found for the USGS 7-.pdfFrom the highest and lowest elevations that your found for the USGS 7-.pdf
From the highest and lowest elevations that your found for the USGS 7-.pdf
 
From the limited information you have in the ('Managing Up (B)- Jada'.pdf
From the limited information you have in the  ('Managing Up (B)- Jada'.pdfFrom the limited information you have in the  ('Managing Up (B)- Jada'.pdf
From the limited information you have in the ('Managing Up (B)- Jada'.pdf
 
From the book- A Short Course in Cloud Physics An air sample contains.pdf
From the book- A Short Course in Cloud Physics  An air sample contains.pdfFrom the book- A Short Course in Cloud Physics  An air sample contains.pdf
From the book- A Short Course in Cloud Physics An air sample contains.pdf
 
From January through December 2012- Gallup interviewed more than 170-0.pdf
From January through December 2012- Gallup interviewed more than 170-0.pdfFrom January through December 2012- Gallup interviewed more than 170-0.pdf
From January through December 2012- Gallup interviewed more than 170-0.pdf
 
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdf
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdfFrenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdf
Frenzied cruise vacationers besiege Tatiana- their excursion coordinat.pdf
 
Freelance reporter Irwin Fletcher is examining the historical voting r.pdf
Freelance reporter Irwin Fletcher is examining the historical voting r.pdfFreelance reporter Irwin Fletcher is examining the historical voting r.pdf
Freelance reporter Irwin Fletcher is examining the historical voting r.pdf
 
Forum Description- Include your sources- 1- The two divisions of the.pdf
Forum Description- Include your sources-  1- The two divisions of the.pdfForum Description- Include your sources-  1- The two divisions of the.pdf
Forum Description- Include your sources- 1- The two divisions of the.pdf
 

Recently uploaded

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 

Recently uploaded (20)

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 

from datetime import datetime def CreateUsers()- print('##### Crea.pdf

  • 1. from datetime import datetime def CreateUsers(): print('##### Create users, passwords, and roles #####') with open('user.txt', 'a') as UserFile: while True: username = GetUserName() if username.upper() == "END": break userpwd = GetUserPassword() userrole = GetUserRole() UserDetail = username + "|" + userpwd + "|" + userrole + "n" UserFile.write(UserDetail) UserFile.close() printuserinfo() def GetUserName(): username = input("Enter username or END to Quit: ") return username def GetUserPassword(): userpwd = input("Enter pwd: ") return userpwd def GetUserRole(): while True: userrole = input("Enter role (Admin or User): ")
  • 2. if userrole == "Admin" or userrole == "User": return userrole else: print('Please input a valid userrole (Admin or User).') def printuserinfo(): UserFile = open("user.txt","r") while True: UserDetail = UserFile.readline() if not UserDetail: break UserDetail = UserDetail.replace("n", "") UserList = UserDetail.split("|") username = UserList[0] userpassword = UserList[1] userrole = UserList[2] print("User Name: ", username, " Password: ", userpassword, " Role: ", userrole) def Login(): with open('User.txt', 'r') as UserList: while True: UserDetail = UserFile.readline() if not UserDetail: return "None", "None" UserDetail = UserDetail.replace("n", "")
  • 3. UserList = UserDetail.split("|") UserName = input("Enter User Name: ") if UserName == UserList[0]: UserRole = UserList[2] return UserRole, UserName def GetEmpName(): empname = input("Enter employee name: ") return empname def GetDatesWorked(): fromdate = input("Enter Start Date (mm/dd/yyyy: ") todate = input("Enter End Date (mm/dd/yyyy") def GetHoursWorked(): hours = float(input('Enter amount of hours worked: ')) return hours def GetHourlyRate(): hourlyrate = float(input ("Enter hourly rate: ")) return hourlyrate def GetTaxRate(): taxrate = float(input ("Enter tax rate: ")) return taxrate def CalcTaxAndNetPay(hours, hourlyrate, taxrate): grosspay = hours * hourlyrate incometax = grosspay * taxrate
  • 4. netpay = grosspay - incometax return grosspay, incometax, netpay def printinfo(DetailsPrinted): TotEmployees = 0 TotHours = 0.00 TotGrossPay = 0.00 TotTax = 0.00 TotNetPay = 0.00 EmpFile = open("Employees.txt","r") while True: rundate = input ("Enter start date for report (MM/DD/YYYY) or All for all data in file: ") if (rundate.upper() == "ALL"): break try: rundate = datetime.strptime(rundate, "%m/%d/%Y") break except ValueError: print("Invalid date format. Try again.") print() continue # skip next if statement and re-start loop while True: EmpDetail = EmpFile.readline() if not EmpDetail:
  • 5. break EmpDetail = EmpDetail.replace("n", "") #remove carriage return from end of line EmpList = EmpDetail.split("|") fromdate = EmpList[0] if (str(rundate).upper() != "ALL"): checkdate = datetime.strptime(fromdate, "%m/%d/%Y") if (checkdate < rundate): continue todate = EmpList[1] empname = EmpList[2] hours = float(EmpList[3]) hourlyrate = float(EmpList[4]) taxrate = float(EmpList[5]) grosspay, incometax, netpay = CalcTaxAndNetPay(hours, hourlyrate, taxrate) print(fromdate, todate, empname, f"{hours:,.2f}", f"{hourlyrate:,.2f}", f"{grosspay:,.2f}", f"{taxrate:,.1%}", f"{incometax:,.2f}", f"{netpay:,.2f}") TotEmployees += 1 TotHours += hours TotGrossPay += grosspay TotTax += incometax TotNetPay += netpay EmpTotals["TotEmp"] = TotEmployees EmpTotals["TotHrs"] = TotHours EmpTotals["TotGrossPay"] = TotGrossPay
  • 6. EmpTotals["TotTax"] = TotTax EmpTotals["TotNetPay"] = TotNetPay DetailsPrinted = True if (DetailsPrinted): #skip of no detail lines printed PrintTotals (EmpTotals) else: print("No detail information to print") def PrintTotals(EmpTotals): print() print(f'Total Number Of Employees: {EmpTotals["TotEmp"]}') print(f'Total Hours Worked: {EmpTotals["TotHrs"]:,.2f}') print(f'Total Gross Pay: {EmpTotals["TotGrossPay"]:,.2f}') print(f'Total Income Tax: {EmpTotals["TotTax"]:,.2f}') print(f'Total Net Pay: {EmpTotals["TotNetPay"]:,.2f}') if __name__ == "__main__": ################################################## ########## Write the line of code to call the method CreateUsers def function_CreateUsers(): print() print("##### Data Entry #####") ########## Write the line of code to assign UserRole and UserName to the function Login## def Login(GetUserRole, UserName): DetailsPrinted = False ###
  • 7. EmpTotals = {} ### ########## Write the if statement that will check to see if UserRole is equal to NONE (NOTE: code will show red error lines until this line is written)#### if GetUserRole == 'NONE': print(UserName," is invalid.") else: # only admin users can enter data ##### write the if statement that will check to see if the UserRole is equal to ADMIN (NOTE: code will show red error lines until this line is written) if GetUserRole == 'ADMIN': EmpFile = open("Employees.txt", "a+") while True: empname = GetEmpName() if (empname.upper() == "END"): break fromdate, todate = GetDatesWorked() hours = GetHoursWorked() hourlyrate = GetHourlyRate() taxrate = GetTaxRate() EmpDetail = fromdate + "|" + todate + "|" + empname + "|" + str(hours) + "|" + str(hourlyrate) + "|" + str(taxrate) + "n" EmpFile.write(EmpDetail) # close file to save data EmpFile.close() printinfo(DetailsPrinted)
  • 8. Question: I can't get the 2nd part of the program to display. The 1st part of the program works fine. The 2ns art of the program starts at def GetEmpName(): The second part asks for employee names, start/end dates, hours, hourly rate, tax rate, gross pay, and net pay. Ty