Question

Nana recently started a consulting business where he is paid based on the number of hours...

Nana recently started a consulting business where he is paid based on the number of hours and minutes he works on client projects.
He needs a time tracking program, where he enters the date and the time he started working on a task, and then the date and time when he finished a particular task.
The program calculates the hours he spent on a task. It then calculates the amount of money Nana made tackling the task.
Note that: Nana is paid $5 dollars per hour.
If Nana works from 11AM to 1:30 PM on Monday 27th July, he would make 2.5 X 5 = $12.5 dollars.

Task
Write a program that would help Nana track his money.
The program calculates the hours he spent on a task.
It then calculates the amount of money Nana made tackling the task.
Time entered and information from the program should be stored in a csv or excel file for future referencing.

I need a very detailed python code for this ASAP. Thank you
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import csv #to append in a csv file
def time_total_minutes(time): #converts a given time into total minutes, 11:00AM -> 11hrs -> 11*60 = 660 mins
minutes = 0 #stores the minutes to be returned
if time[-2:] == "PM" and int(time[:2]) < 12: #if the entered time is in between 1:00PM and 11:59PM
minutes += ((int(time[:2])+12)*60)
minutes += (int(time[3:5]))
elif time[-2:] == "AM" and int(time[:2]) == 12: #if entered time is in AM
minutes += (int(time[3:5]))
else:
minutes += (int(time[:2])*60)
minutes += (int(time[3:5]))
return minutes
  
  
while(True): #takes proper input for start_time according to the specification in print statements also checks for a valid time
start_time = input("Enter the start time: (hh:mm)(AM/PM)")
k = start_time #hh should be in between 0 and 12 and mm should be in between 0 and 59 last two values should be PM or AM and hh should be followed by ':'
if k[2] == ":" and k[-2:] in ["AM","PM"] and (int(k[:2]) >= 0 and int(k[:2]) <= 12) and (int(k[3:5]) >= 0 and int(k[3:5]) <= 59):
break #if valid then break
print("Retry!")
while(True): #takes proper input for end_time according to the specification in print statements also checks for a valid time
end_time = input("Enter the end time: (hh:mm)(AM/PM)")
k = end_time #hh should be in between 0 and 12 and mm should be in between 0 and 59 last two values should be PM or AM and hh should be followed by ':'
if k[2] == ":" and k[-2:] in ["AM","PM"] and (int(k[:2]) >= 0 and int(k[:2]) <= 12) and (int(k[3:5]) >= 0 and int(k[3:5]) <= 59):
break #if valid then break
print("Retry!")
while(True): #takes proper input for date according to the specification in print statements
date = input("Enter the date like dd/mm/yyyy")
d = int(date[:2]) #takes the date
m = int(date[3:5]) #takes the month
y = int(date[-4:]) #takes the year
if date[2] == '/' and date[5] == '/' and d >= 1 and d <= 31 and m >= 1 and m <= 12 and y >= 1990 and y <= 2050:
break #3rd and 6th values should be '/' and 1<=d<=31 and 1<=m<=12 and 1990<=y<=2050
print("Retry!")
start_mins = time_total_minutes(start_time) #converts into the total minutes
end_mins = time_total_minutes(end_time) #converts into the total minutes
if end_mins >= start_mins: #checs if end_mins >= start_mins
total_mins = end_mins - start_mins #gets the difference between the two times
h = (total_mins/60) #converts into total hours of work in float
total_money = h * 5 #finds the total dollars
print("Money: $"+str(total_money)) #prints
  
#to append in a csv file
list_ = [start_time,end_time,date,round(h,2),round(total_money,2)] #convert all the data into a list
myfile = open('money.csv','a') #open the desried file
wrtr = csv.writer(myfile, delimiter=',', quotechar='"') #creates a writer object to the file
wrtr.writerow(list_) #writes the list in the next row
myfile.flush() #flushes the contents of myfile
myfile.close() #closes the file
else:
print("End time is less that Start time of the day")

Add a comment
Know the answer?
Add Answer to:
Nana recently started a consulting business where he is paid based on the number of hours...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 3-6 Fred Klein started his own business recently. He began by depositing $5,000 of his...

    Problem 3-6 Fred Klein started his own business recently. He began by depositing $5,000 of his own money (equity) in a business account. Once he'd done that his balance sheet was as follows. Liabilities and Assets Equity Cash $5,000 Equity $5,000 Total Assets $5,000 Total $5,000 During the next month, his first month of business, he completed the following transactions. (All payments were made with checks out of the bank account.) Purchased $4,000 worth of inventory, paying $1,500 down and...

  • High-End Lifts uses a volume-based, plant-wide approach to allocating overhead. They use direct-labor hours as the...

    High-End Lifts uses a volume-based, plant-wide approach to allocating overhead. They use direct-labor hours as the cost driver for determining the budgeted rate. You will need to derive the predetermined overhead rate for them. First few images are information for the actual problems. Please help!! Challenge 2: Job-Order Costing for Customized Work Based on your advice, High-End Lifts has moved forward and set up the production process to build all of its residential elevators in- house. In the past, High-End...

  • CASE 6 Using Ex-Cons to Teach Business business school with a master's degree, worked as a...

    CASE 6 Using Ex-Cons to Teach Business business school with a master's degree, worked as a Ethics at MCL devised a 56 million money launderin home and served two years in federal prison. AL After the Enron scandal and he was the way he became divorced and unemployed, and Tyon, and Adelphia debacles that wed a couple of to move back in with his parents. As Busw. We years later, the business ethics industry really started to reported, it was...

  • BF SWINGS Ben Floyd really enjoyed wood shop in high school, so he used an inheritance to buy som...

    BF SWINGS Ben Floyd really enjoyed wood shop in high school, so he used an inheritance to buy some basic woodworking tools. He started out doing odd jobs, and then one day he made a porch swing for his house. Several people saw it and asked him to make one for them. Word of mouth brought him many customers. In June of 1991 he married Bobbie Ruth, a marketing graduate. Bobbie Ruth saw a chance to expand the swing business...

  • Bath Salts Online Store 1. Business Objective: Owners want to expand customer base and increase profits...

    Bath Salts Online Store 1. Business Objective: Owners want to expand customer base and increase profits while still keeping a relatively low overhead. a. Expand customer base  Create online store to supplement their Etsy account b. Increase product output  buy more materials to qualify for better wholesale price 2. Business Case: Bath Salts Boutique has existed as an LLC (Limited Liability Company) for the last 5 years. To keep costs down owners Craig and Brooke have not invested...

  • Business Law: Text and Cases 14th Edition Please answer Number 3 I already have questions 1...

    Business Law: Text and Cases 14th Edition Please answer Number 3 I already have questions 1 and 2 answered. 1)   Assume you are the attorney for the Landlord. List the legal grounds under which you would sue the Tenants and list the arguments you would use to persuade the Judge to rule in your favor. Also list the defenses you would raise to the counterclaim brought by Tenants. Support your answers with legal reasoning and conclusions. The lease was for...

  • Hi can You help me make a summary about this short article, and also tell me...

    Hi can You help me make a summary about this short article, and also tell me how it affects me economically as US citizen ? As Government Shutdown Persists, Americans Feel the Bite Members of the Secret Service on Monday outside the White House. Virtually every employee with the agency is required to work during the shutdown.CreditDoug Mills/The New York Times Image Members of the Secret Service on Monday outside the White House. Virtually every employee with the agency is...

  • Case 2: Going to The X-Stream Gil Reihana is the chief executive officer of X-Stream, an...

    Case 2: Going to The X-Stream Gil Reihana is the chief executive officer of X-Stream, an Auckland-based company that assembles personal computers for the New Zealand and Australian markets, and sells them through a number of chain stores and independent retailers. He started the company six years ago, at the age of 25, after graduating from university with a Bachelor’s degree in Information Technology and Management. To establish the company, Reihana invested $300 000 he had inherited and persuaded various...

  • 1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below,...

    1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below, how would you describe THE COMPANY’s approach to recruitment, before and after the implementation of the Brand Ambassador Program? How did the use of social media lead to the revision of the whole approach regarding recruitment? How ‘THE COMPANY’ Developed a Brand Ambassador Program At ‘THE COMPANY’ we usually categorize Employment Brand at ‘THE COMPANY’ into four big ‘buckets’: candidate experience, brand ambassador programs,...

  • Budgeting for an Academic Department at a State University: Can You Believe the Numbers? INTRODUCTION You...

    Budgeting for an Academic Department at a State University: Can You Believe the Numbers? INTRODUCTION You are the senior accounting faculty member in the business school and your dean, Dean Weller, is asking for help. She is very discouraged after a midyear budget meeting with the Vice President of Finance. The college's Department of Social Work has a large budget deficit, and because of this the VP is inclined towards closing the department entirely or closing its bachelor's program. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT