Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

During the tax season, every Friday, the J&J accounting firm provides assistance

ID: 3800398 • Letter: D

Question

During the tax season, every Friday, the J&J accounting firm provides assistance to people who prepare their own tax returns. Their charges are as follows: a. If a person has low income (<= 25,000) and the consulting time is less than or equal to 30 minutes, there are no charges; otherwise, the service charges are 40% of the regular hourly rate for the time over 30 minutes. b. For others, if the consulting time is less than or equal to 20 minutes, there are no service charges; otherwise, service charges are 70% of the regular hourly rate for the time over 20 minutes. (For example suppose that a person has low income and spent 1 hour and 15 minutes, and the hourly rate is $70.00. Then the billing amount is 70.00 X 0.40 X (45 / 60) = 21.00). During the tax season, every Friday, the J&J accounting firm provides assistance to people who prepare their own tax returns. Their charges are as follows: The customer record should include a 6-digit customer id (customer id will be generated by the program). The customer id should be used as a key to retrieve the customer information (first and last name, income, hourly rate, consulting time, income, and billing amount). Program should use a function, generateRecord, to create and add the customer record to the database (a dict that stores customers’ information). generateRecord function takes first and last name, hourly rate, the total consulting time, and income as arguments. The program should calculate the billing amount and append/include it in the customer record. Your program must contain a function, generateBillAmount that takes as input the hourly rate, the total consulting time, and the customer income. The generateBillAmount should return the billing amount. The program should use a loop to process multiple customers. To exit the loop, the user should hit enter without entering customer information. Upon exiting the loop, the program should print each customer information. If the database does not contain data, the program should print the following: “ No customer to print” Customer information (first and last name, income, hourly rate, consulting time, income, and billing amount) must be stored in a tuple I really need help with this program using python. Could I get the source code in the steps and comments in functions.

Explanation / Answer

# function to calculate bill amount
def generateBillAmount(hourlyRate, consultingTime, income):
if (income <= 25000):
if (consultingTime <= 30):
return 0
else:
return hourlyRate*(consultingTime - 30)*.4
else:
if (consultingTime <= 20):
return 0
else:
return hourlyRate*(consultingTime - 20)*.7

# dict to store customer record
customerRecordDict = {}

# global variable to keep track of customer id
customer_id = 100000

# function to calculate bill amount and store in global dict
def generateRecord(firstName, lastName, hourlyRate, consultingTime, income):
global customer_id
customer_id = customer_id + 1
billAmount = generateBillAmount(float(hourlyRate), int(consultingTime), float(income))
  
customerRecordDict[customer_id] = (firstName, lastName, hourlyRate, consultingTime, income, billAmount)

data = raw_input("Enter customer data: ")
# expect data to be space seprated value of firstName, lastName, hourlyRate, consultingTime, income
# loop over to generate record and get data from terminal,Exit loop on empty line
while(data):
(firstName, lastName, hourlyRate, consultingTime, income) = data.split()
generateRecord(firstName, lastName, hourlyRate, consultingTime, income)
data = raw_input("Enter customer data: ")

# printing data
if not customerRecordDict:
print "No customer to print"
else:
for key in customerRecordDict.keys():
(firstName, lastName, hourlyRate, consultingTime, income, billAmount) = customerRecordDict[key]
print "Customer_id: " + str(key),
print "Customer Name: " + firstName + " " + lastName,
print "Hourly Rate: " + hourlyRate,
print "Consultng Time: " + consultingTime,
print "Income: " + income,
print "bill amount: " + str(billAmount)
'''
sample run result
sh-4.3$ python main.py
Enter customer data: first last 70.0 25 24000   
Enter customer data: first1 last1 70.0 25 26000   
Enter customer data: first2 last2 70.0 19 27000   
Enter customer data: first3 last3 70.0 75 24000   
Enter customer data:
Customer_id: 100001 Customer Name: first last Hourly Rate: 70.0 Consultng Time: 25 Income: 24000 bill amount: 0   
Customer_id: 100002 Customer Name: first1 last1 Hourly Rate: 70.0 Consultng Time: 25 Income: 26000 bill amount: 245.0   
Customer_id: 100003 Customer Name: first2 last2 Hourly Rate: 70.0 Consultng Time: 19 Income: 27000 bill amount: 0   
'''

# link to code https://goo.gl/PuUI5B