elifmenu == 'gr': file6 = open('tasks.txt', 'r') tasks = file6.readlines() total_tasks = len(tasks) total_completed_tasks = 0 total_uncompleted_tasks = 0 total_task_overdue = 0 fortaskintasks: assigned_user, task_title, task_description, current_date, task_due, completed_question = task.strip().split(", ") task_due_2 = parser.parse(task_due) iftask[-1] == "Yes": total_completed_tasks += 1 else: total_uncompleted_tasks += 1 iftask_due_2 < datetime.today(): total_task_overdue += 1 incomplete_percentage = round(total_completed_tasks / total_tasks * 100, 2) overdue_percentage = round(total_task_overdue / total_tasks * 100, 2) print("Report Generated in file: task_overview.txt") file7 = open('task_overview.txt', 'a') file7.write(f"Number of tasks: {total_tasks}\n") file7.write(f"Number of completed tasks: {total_completed_tasks}\n") file7.write(f"Number of uncompleted tasks: {total_uncompleted_tasks}\n") file7.write(f"Number of overdue tasks: {total_task_overdue}\n") file7.write(f"Perentage of incomplete tasks: {incomplete_percentage}\n") file7.write(f"Percentage of overdue tasks: {overdue_percentage}\n") file8 = open('user_overview.txt', 'a') file9 = open('user.txt', 'r') users = file9.readlines()   foruserinusers: usernames = user.strip() assigned_tasks = 0 completed_tasks = 0 incompleted_tasks = 0 overdue_tasks = 0 fortaskintasks: task = task.strip().split(", ") iftask[1] == usernames: assigned_tasks += 1 iftask[-1] == "Yes": completed_tasks += 1 else: incompleted_tasks += 1 iftask_due_2 < datetime.today(): overdue_tasks += 1 assigned_percent = round(assigned_tasks / total_tasks * 100, 2) completed_percent = round(completed_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0 incomplete_percent = round(incompleted_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0 overdue_percent = round(overdue_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0 file8.write(f"For user: {usernames}\n") file8.write(f"The number of tasks: {assigned_tasks}\n") file8.write(f"Number of completed tasks:{completed_tasks}\n") file8.write(f"Number of incompleted tasks:{incompleted_tasks}\n") file8.write(f"Number of overdue tasks:{overdue_tasks}\n") file8.write(f"Percentage of assigned tasks: {assigned_percent}%\n") file8.write(f"Percentage of completed tasks: {completed_percent}%\n") file8.write(f"Percentage of incomplete tasks: {incomplete_percent}%\n") file8.write(f"Percentage of overdue tasks: {overdue_percent}%\n") print("Report Generated in file: user_overview.txt")   file6.close() file7.close() file8.close() file9.close() question:   for user in users: it is only printing from the last user, instead of all of the users. lets say there is bob and rob, it will only print for rob because he is the last on the list, how do i make it read for all of the users.   IT IS also no counting the tasks from the users, instead it is just printing 0. How do i get it to actually count the tasks and all the information needed.   def view_mine():   file4 = open('tasks.txt','r+') view_tasks = file4.readlines()   forindex, lineinenumerate(view_tasks): assigned_user, task_title, task_description, current_date, task_due, completed_question = line.strip().split(", ") ifassigned_user == login_username: print(f"Task Number:\t{index}\nAssigned to:\t{assigned_user}\nTitle:\t\t{task_title}\nDescription:\t{task_description}\nDate assigned:\t{current_date}\nDue date:\t{task_due}\nTask completed?\t{completed_question}\n") else: print("You are not authorised to see the task list.") file5 = open('tasks.txt', 'a') the_choice = input("Would you like to mark your task as complete = 'c' or edit your tasks = 'e', or return backt to main menu = '-1':").lower() ifthe_choice == '-1': print(menu) elifthe_choice == 'c': task_number = input("Enter the number of which task number you would like to mark as complete: ") task_choice = view_tasks[int(task_number)-1] assigned_user, task_title, task_description, current_date, task_due, completed_question = task_choice.strip().split(", ") ifcompleted_question == "No": task_choice = completed_question.replace(", No",", Yes") file5.writelines(task_choice) print("Task marked as complete") else: print("This task has already been completed.") elifthe_choice == 'e': task_number = input("Enter the number of which task number you would like to edit: ") ifcompleted_question == "No": new_assigned_user = input("Assign task to username: ") new_task_due = input("Enter due date: ") forupdated_tasksinview_tasks: assigned_user, task_title, task_description, current_date, task_due, completed_question = updated_tasks.strip().split(", ") updated_tasks = updated_tasks.replace(assigned_user , new_assigned_user) updated_tasks = updated_tasks.replace(task_due, new_task_due) file5.writelines(updated_tasks) else: print("This task has already been completed and cannot be edited") file4.close() file5.close() return()   question:   for 'vm'   when the user is asked if they want to complete the task or edit it. if they choose to complete the task, it is not replacing the No with Yes, its just printing NoYes.  then its also not chaning the first task?

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter9: Sequential Access Files And Menus
Section: Chapter Questions
Problem 2E
icon
Related questions
Question
elifmenu == 'gr':

file6 = open('tasks.txt', 'r')
tasks = file6.readlines()
total_tasks = len(tasks)
total_completed_tasks = 0
total_uncompleted_tasks = 0
total_task_overdue = 0

fortaskintasks:
assigned_user, task_title, task_description, current_date, task_due, completed_question = task.strip().split(", ")
task_due_2 = parser.parse(task_due)
iftask[-1] == "Yes":
total_completed_tasks += 1
else:
total_uncompleted_tasks += 1
iftask_due_2 < datetime.today():
total_task_overdue += 1
incomplete_percentage = round(total_completed_tasks / total_tasks * 100, 2)
overdue_percentage = round(total_task_overdue / total_tasks * 100, 2)
print("Report Generated in file: task_overview.txt")


file7 = open('task_overview.txt', 'a')
file7.write(f"Number of tasks: {total_tasks}\n")
file7.write(f"Number of completed tasks: {total_completed_tasks}\n")
file7.write(f"Number of uncompleted tasks: {total_uncompleted_tasks}\n")
file7.write(f"Number of overdue tasks: {total_task_overdue}\n")
file7.write(f"Perentage of incomplete tasks: {incomplete_percentage}\n")
file7.write(f"Percentage of overdue tasks: {overdue_percentage}\n")

file8 = open('user_overview.txt', 'a')

file9 = open('user.txt', 'r')
users = file9.readlines()
 
foruserinusers:
usernames = user.strip()
assigned_tasks = 0
completed_tasks = 0
incompleted_tasks = 0
overdue_tasks = 0
fortaskintasks:
task = task.strip().split(", ")
iftask[1] == usernames:
assigned_tasks += 1
iftask[-1] == "Yes":
completed_tasks += 1
else:
incompleted_tasks += 1
iftask_due_2 < datetime.today():
overdue_tasks += 1
assigned_percent = round(assigned_tasks / total_tasks * 100, 2)
completed_percent = round(completed_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0
incomplete_percent = round(incompleted_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0
overdue_percent = round(overdue_tasks / assigned_tasks * 100, 2) ifassigned_tasks != 0else0

file8.write(f"For user: {usernames}\n")
file8.write(f"The number of tasks: {assigned_tasks}\n")
file8.write(f"Number of completed tasks:{completed_tasks}\n")
file8.write(f"Number of incompleted tasks:{incompleted_tasks}\n")
file8.write(f"Number of overdue tasks:{overdue_tasks}\n")
file8.write(f"Percentage of assigned tasks: {assigned_percent}%\n")
file8.write(f"Percentage of completed tasks: {completed_percent}%\n")
file8.write(f"Percentage of incomplete tasks: {incomplete_percent}%\n")
file8.write(f"Percentage of overdue tasks: {overdue_percent}%\n")

print("Report Generated in file: user_overview.txt")
 
file6.close()
file7.close()
file8.close()
file9.close()
question:
 
for user in users:
it is only printing from the last user, instead of all of the users. lets say there is bob and rob, it will only print for rob because he is the last on the list, how do i make it read for all of the users.
 
IT IS also no counting the tasks from the users, instead it is just printing 0. How do i get it to actually count the tasks and all the information needed.
 
def view_mine():
 
file4 = open('tasks.txt','r+')
view_tasks = file4.readlines()
 

forindex, lineinenumerate(view_tasks):
assigned_user, task_title, task_description, current_date, task_due, completed_question = line.strip().split(", ")
ifassigned_user == login_username:
print(f"Task Number:\t{index}\nAssigned to:\t{assigned_user}\nTitle:\t\t{task_title}\nDescription:\t{task_description}\nDate assigned:\t{current_date}\nDue date:\t{task_due}\nTask completed?\t{completed_question}\n")
else:
print("You are not authorised to see the task list.")

file5 = open('tasks.txt', 'a')

the_choice = input("Would you like to mark your task as complete = 'c' or edit your tasks = 'e', or return backt to main menu = '-1':").lower()
ifthe_choice == '-1':
print(menu)

elifthe_choice == 'c':
task_number = input("Enter the number of which task number you would like to mark as complete: ")
task_choice = view_tasks[int(task_number)-1]
assigned_user, task_title, task_description, current_date, task_due, completed_question = task_choice.strip().split(", ")
ifcompleted_question == "No":
task_choice = completed_question.replace(", No",", Yes")
file5.writelines(task_choice)
print("Task marked as complete")
else:
print("This task has already been completed.")

elifthe_choice == 'e':
task_number = input("Enter the number of which task number you would like to edit: ")
ifcompleted_question == "No":
new_assigned_user = input("Assign task to username: ")
new_task_due = input("Enter due date: ")
forupdated_tasksinview_tasks:
assigned_user, task_title, task_description, current_date, task_due, completed_question = updated_tasks.strip().split(", ")
updated_tasks = updated_tasks.replace(assigned_user , new_assigned_user)
updated_tasks = updated_tasks.replace(task_due, new_task_due)
file5.writelines(updated_tasks)
else:
print("This task has already been completed and cannot be edited")

file4.close()
file5.close()
return()
 
question:
 
for 'vm'
 
when the user is asked if they want to complete the task or edit it. if they choose to complete the task, it is not replacing the No with Yes, its just printing NoYes. 
then its also not chaning the first task?
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,