Uploaded by Subarashi Urbina

Title-Page-NCE-1102-Case-Study

advertisement
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
APPLICATION PROGRAM USING C: TASK MASTER
A Case Study Submitted to the
Faculty of Computer Engineering Department
of the University of the East, Caloocan City
In Partial Fulfillment of the Requirements in
Computer Fundamentals and Programming (NCE 1102)
Bautista, Nicole Ann P.
Galang, Eujan Nicolai
Ordona, Cyden Louise E.
Placido, Andrei
Urbina, Carl Jeric
Dr. Joan P. Lazaro
Professor
May 2024
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
I.
Introduction
Managing tasks can be difficult at times especially when you don’t have enough
time or there are multiple tasks needed to be done. The researchers created a program that
is called Task Master, a program that will help every individual who is having difficulties
when it comes to time management and organizing tasks. Using C language code
programming, the researchers manage to create a program that lets you create, manage, and
organize your own tasks for the day or for each month.
Combined with ideas and experiences, the Task Master was first created to help
civil engineering students to manage their time and tasks so that cramming doesn’t need to
be the main option for them, but by revising it, the Task Master can also be used by a lot
of people who struggles with time management and jammed schedules. This program can
help a lot of people, especially those who have office jobs, university students, and
professors. By using the Task Master in everyday life, an individual can ensure to manage
one’s time, organize tasks accordingly, execute work properly, and finish tasks in a
productive manner.
II.
Description and Function of the project
The Task Master is a C program that is developed for an individual to manage
one’s tasks. It aims to help users to manage their everyday tasks and meet their deadlines
on time. It functions similarly to the "To Do List" that people make traditionally and often
stick to the tables, refrigerators or office desk, but this one is created using the C Program.
Every task has a description, an estimated completion date, and a completion
status. While anyone can benefit from this C program, those with demanding schedules
and responsibilities such as teachers, students, and professionals will find it especially
helpful. By keeping us informed about our assignments and deadlines, and allowing us to
mark them as completed, Task Master's main objective is to increase our productivity with
its user-friendly scheduling and task management capabilities.
Taskmaster is a tool for anyone to make their tasks more doable–- its functionality
is the same as those people use at home. Furthermore, it is where tasks can be created,
deadlines can be established, and completion marking is more possible, which allows for
more organized work to be monitored.
The following are Task Master's primary functions:
• Adding a Task – Through this function, users can quickly enter a task's description and
indicate when it is due by entering the day of the month. Since the array function will be
used as the storage, the program will be well-documented and scheduled.
• Viewing All Tasks – With this function, users can see every task they submitted, arranged
according to their due dates. The tasks are arranged in ascending order according to their
due dates so that users can plan their tasks appropriately and know which ones are due the
earliest.
• Viewing Today Tasks – This function of the program shows the current date and then
displays the tasks that are due on the that date. This allows users to focus on that due date
task first.
• Marking Tasks as Completed – Users can mark their task when it is completed, this
helps users distinguish finished, unfinished and pending tasks.
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
• Deleting Tasks – Users can also delete tasks that are no longer important or needed for
them to focus on the most important tasks.
In addition to the primary functions, this program can also Save Task to File, this
allows users to preserve their data when the program is closed.
III.
Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAX_TASKS 100
#define MAX_LENGTH 100
#define FILENAME "tasks.txt"
struct Task
{
char description[MAX_LENGTH];
int completed;
struct tm due_date;
};
struct Task tasks[MAX_TASKS];
int numTasks = 0;
int compareTasks(const void *task1, const void *task2)
{
struct Task *t1 = (struct Task *)task1;
struct Task *t2 = (struct Task *)task2;
return difftime(mktime(&t1->due_date), mktime(&t2->due_date));
}
void addTask(char *description, int day)
{
if (numTasks < MAX_TASKS)
{
strcpy(tasks[numTasks].description, description);
tasks[numTasks].completed = 0;
tasks[numTasks].due_date.tm_year = 2024 - 1900;
tasks[numTasks].due_date.tm_mon = 4;
tasks[numTasks].due_date.tm_mday = day;
numTasks++;
printf("\n\n\t\t
**Task added successfully.**\n\n");
}
else
{
printf("\n\n\t\t **Cannot add task. Task list is full.**\n\n");
}
}
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
void viewTasks() {
if (numTasks == 0)
{
printf("\n\n\t\t\t**No task to display.**\n\n");
}
else
{
// Sort tasks by due date
qsort(tasks, numTasks, sizeof(struct Task), compareTasks);
printf("\nAll Tasks (Sorted by Due Date):\n");
for (int i = 0; i < numTasks; i++)
{
printf("%d. [%c] %s - Due: %d-%02d-%02d\n", i + 1, tasks[i].completed ? 'X' : ' ',
tasks[i].description,
tasks[i].due_date.tm_year + 1900, tasks[i].due_date.tm_mon + 1,
tasks[i].due_date.tm_mday);
}
printf("\n");
}
}
void viewTodaysTasks()
{
if (numTasks == 0)
{
printf("\n\n\t\t\t**No task to display.**\n\n");
}
else
{
time_t t = time(NULL);
struct tm *today = localtime(&t);
printf("\nToday is %d-%02d-%02d\n", today->tm_year + 1900, today->tm_mon +
1, today->tm_mday);
printf("Today's Tasks:\n");
int found = 0;
for (int i = 0; i < numTasks; i++)
{
if (tasks[i].due_date.tm_year == today->tm_year &&
tasks[i].due_date.tm_mon == today->tm_mon &&
tasks[i].due_date.tm_mday == today->tm_mday)
{
found = 1;
printf("%d. [%c] %s \n", i + 1, tasks[i].completed ? 'X' : ' ',
tasks[i].description);
}
}
if (!found)
{
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
printf("\n\n\t\t\t**No task is due today.**\n");
}
printf("\n");
}
}
void completeTask(int index)
{
if (index >= 1 && index <= numTasks)
{
tasks[index - 1].completed = 1;
printf("\n\n\t\t **Task marked as completed.**\n\n");
}
else
{
printf("\n\n\t\t\t**Invalid task index.**\n\n");
}
}
void deleteTask(int index)
{
if (index >= 1 && index <= numTasks)
{
for (int i = index - 1; i < numTasks - 1; i++)
{
strcpy(tasks[i].description, tasks[i + 1].description);
tasks[i].completed = tasks[i + 1].completed;
tasks[i].due_date = tasks[i + 1].due_date;
}
numTasks--;
printf("\n\n\t\t **Task deleted successfully.**\n\n");
}
else
{
printf("\n\n\t\t\t**Invalid task index.**\n");
}
}
void saveTasksToFile()
{
FILE *file = fopen(FILENAME, "w");
if (file == NULL)
{
printf("Error opening file for writing.\n");
return;
}
for (int i = 0; i < numTasks; i++)
{
fprintf(file, "%s,%d,%d-%02d-%02d\n", tasks[i].description, tasks[i].completed,
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
tasks[i].due_date.tm_year + 1900, tasks[i].due_date.tm_mon + 1,
tasks[i].due_date.tm_mday);
}
fclose(file);
printf("\n\t\t
****Tasks saved to file.****\n");
}
void loadTasksFromFile() {
FILE *file = fopen(FILENAME, "r");
if (file == NULL) {
printf("No tasks found.\n");
return;
}
char line[MAX_LENGTH];
while (fgets(line, sizeof(line), file) != NULL) {
char *description = strtok(line, ",");
int completed = atoi(strtok(NULL, ","));
char *dateStr = strtok(NULL, ",");
int year, month, day;
sscanf(dateStr, "%d-%d-%d", &year, &month, &day);
addTask(description, day);
if (completed)
tasks[numTasks - 1].completed = 1;
}
fclose(file);
}
int main()
{
loadTasksFromFile();
int choice;
char description[MAX_LENGTH];
int index;
int day;
do {
printf("=====================================================");
printf("\n\n\t\t\t Task Master\n\n");
printf("=====================================================");
printf("\n\n\tMenu:\n");
printf("\n\t\t1. Add Task\n");
printf("\t\t2. View All Tasks (Sorted by Due Date)\n");
printf("\t\t3. View Today's Tasks\n");
printf("\t\t4. Mark Task as Completed\n");
printf("\t\t5. Delete Task\n");
printf("\t\t0. Exit\n\n");
printf("==================================================\n\n");
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("\nEnter task description: ");
getchar();
fgets(description, sizeof(description), stdin);
description[strcspn(description, "\n")] = '\0';
printf("Enter day of month for due date: ");
scanf("%d", &day);
addTask(description, day);
break;
case 2:
viewTasks();
break;
case 3:
viewTodaysTasks();
break;
case 4:
printf("\nList of tasks: \n");
for (int i = 0; i < numTasks; i++)
{
printf("%d. [%c] %s - Due: %d-%02d-%02d\n", i + 1, tasks[i].completed ?
'X' : ' ', tasks[i].description,
tasks[i].due_date.tm_year + 1900, tasks[i].due_date.tm_mon + 1,
tasks[i].due_date.tm_mday);
}
if (numTasks == 0)
{
printf("\n\n\t\t **No task to mark as complete.**\n\n");
break;
}
printf("\nEnter task index to mark as completed: ");
scanf("%d", &index);
completeTask(index);
break;
case 5:
printf("\nList of tasks: \n");
for (int i = 0; i < numTasks; i++)
{
printf("%d. [%c] %s - Due: %d-%02d-%02d\n", i + 1, tasks[i].completed ?
'X' : ' ', tasks[i].description,
tasks[i].due_date.tm_year + 1900, tasks[i].due_date.tm_mon + 1,
tasks[i].due_date.tm_mday);
}
if (numTasks == 0)
{
printf("\n\n\t\t\t**No task to delete.**\n\n");
break;
}
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
printf("\nEnter task index to delete: ");
scanf("%d", &index);
deleteTask(index);
break;
case 0:
saveTasksToFile();
printf("\t\t\t\tExiting...\n");
break;
default:
printf("\n\n\t\t**Invalid choice. Please try again.**\n\n");
}
} while (choice != 0);
return 0;
}
IV.
Sample Output
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
V.
Conclusion
The Task Master program has been proven to be a helpful tool for time
management and organizing of tasks. Created using C programming, Task Master allows
users to add tasks, view tasks by date, mark tasks as completed, delete tasks, and save tasks
for later use. This makes it easier for professionals, students, and teachers to organize their
daily or monthly tasks. Furthermore, Task Master helps users to stay composed and
controlled of their works by keeping their tasks organized and sorted by due date. Thus,
users can focus on what needs to be done each day and track their progress by marking
tasks as completed, which ensures that important tasks are not forgotten and done on time.
The key feature of Task Master is its ability to save tasks to a file and load them
later. This means that users won’t lose their tasks even after closing the program, adding
to the convenience and reliability of the tool.
In conclusion, Task Master stands out as a practical, user-friendly program that
simplifies task management and enhances time efficiency. It addresses the common
challenges faced in task organization and provides a valuable tool for anyone who wants
to manage their daily activities and aim for productivity. Thus, this project shows that C
programming can be used to create practical tools that make everyday tasks manageable
and viable.
UNIVERSITY OF THE EAST CALOOCAN CAMPUS
VI.
Group Meetings
Download