From dec8408ec4266c91c29a42b43dd21ea5988836a7 Mon Sep 17 00:00:00 2001 From: Bettina Date: Mon, 11 Jul 2016 09:41:16 -0400 Subject: [PATCH 1/3] Project Proposal --- proposal.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 proposal.txt diff --git a/proposal.txt b/proposal.txt new file mode 100644 index 0000000..1713c3c --- /dev/null +++ b/proposal.txt @@ -0,0 +1,7 @@ +For my final project I will make a reminders calendar. I will give the user the option to make reminders that they can categorise and I wll be able to let them retreive this information whenever they ask for it. This program will ask for the reminder name, date, time, and urgency ranking. + +I will use a struct to ask for the reminder requirements. I will use if statements for pulling up the data that they logged. functions to help me print out the information in an organised manner. I will use arrays and strings to set each information and put them in place. I will use loops to question whether they want to continue making more reminders or not with conditional statements. + +I chose this program for my project because I am always so forgetful. This program will let me input all my reminders for the day which is very helpful for people like me. + +I will only be using and to make strings. From f77a14bcbc9a6409e1e0e7f41e5a47e32f351462 Mon Sep 17 00:00:00 2001 From: Bettina Date: Fri, 15 Jul 2016 15:59:55 -0400 Subject: [PATCH 2/3] SORRY FOR THE BUGS AND ERRORS I TRIED --- README.txt | 5 +++ reminders.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 README.txt create mode 100644 reminders.c diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..0aadfbe --- /dev/null +++ b/README.txt @@ -0,0 +1,5 @@ +Bettina Benitez + +My program is a reminders program that lets the user add a reminder. The reminder asks for title, day, time, priority. To use the program, you just have to follow the instructions using abc or 123. + +It can add more reminders or retrieve reminders. If you want to end the program, you can press 'c' as it says on the instructions/ diff --git a/reminders.c b/reminders.c new file mode 100644 index 0000000..e270025 --- /dev/null +++ b/reminders.c @@ -0,0 +1,112 @@ +//Bettina Benitez +#include +#include + +typedef struct { + char title[50][500]; + char day[50][10]; + char time[50][50]; + int priority[50]; +} reminders; + +void getRetrieve(reminders x, int *ptrNum); + +void getWelcome (char* ptrNew, int* ptrNum) { + printf("Welcome to Weekly Reminders. In this program, you will be able to input any reminder into the database and retrieve it any time you want.\n\nFor each reminder, you can label it and give it a title, the day of the week it's due for, the time it's due for, and the level of urgency from 1-3 (1 being the lowest and 3 being the highest priority)\n\nBegin a reminder? (y/n): "); + scanf("%c", &*ptrNew); + if (*ptrNew == 'y') { + *ptrNum; + (*ptrNum)++; + } + else if (*ptrNew == 'n') + printf("Goodbye!"); + else + printf("%c is not a valid response\n", *ptrNew); +} + +void getInfo (reminders x, int* ptrNum) { + printf("\nReminder: %d", *ptrNum); + printf("\nEnter your reminder a title (500 character max):\n"); + while (getchar () != '\n'); + fgets(x.title[*ptrNum], sizeof(x.title[*ptrNum]), stdin); + printf("Enter the day this reminder is due: \n"); + scanf("%s", x.day[*ptrNum]); + printf("Enter the time of the reminder: \n"); + scanf("%s", x.time[*ptrNum]); + printf("Enter the level of priority (1-3): \n"); + scanf("%d", &x.priority[*ptrNum]); + printf("\nReminder Recap:\n"); + printf("%s", x.title[*ptrNum]); + printf("Day:%s\nTime:%s\nPriority Level:%d\n", x.day[*ptrNum], x.time[*ptrNum], x.priority[*ptrNum]); + char answer; + while(getchar () != '\n'); + while (answer != 'y') { + printf("\nAre you sure about your reminder? (y/n): "); + scanf("%c", &answer); + if (answer == 'y') + printf("\nYour reminder has been saved!\n"); + else if (answer == 'n') + getInfo(x, ptrNum); + else + printf("Invalid option\n"); + } +} + +void getOptions (reminders x, int* ptrNum) { + int check = 0; + char ptrOpt; + printf("\nWhat would you like to do?\na) make a new reminder b) retrieve a reminder c) end program: "); + while (check == 0) { + scanf("%c", &ptrOpt); + if (ptrOpt == 'a') { + *ptrNum; + (*ptrNum)++; + getInfo(x, ptrNum); + printf("What would you like to do?: "); + check = 0; + } + if (ptrOpt == 'b') { + printf("\nWhat information would you like to retreieve? Choose from the following:\n1) Title c)end program: "); + int opt; + char title[100]; + scanf("%d", &opt); + if (opt == 1) { + printf("Enter the title?\n"); + while (getchar() != '\n'); + fgets(title, sizeof(title), stdin); + printf("title is %s\n", title); + char *pos; + if ((pos = strchr(title, '\n')) != NULL) + *pos = '\0'; + printf("title is %s\n", title); + for (int i = 1; i <= *ptrNum; i++) { + printf("reminder title: %s\n", x.title[i]); + if (strcmp(x.title[i], title) == 0) + printf("Title:%sDay:%s\nTime:%s\nPriority Level:%d\n", x.title[i], x.day[i], x.time[i], x.priority[i]); + else + printf("Not valid\n"); + printf("What would you like to do?: \n"); + } + check = 0; + } + } + if (ptrOpt == 'c') { + printf("\nGoodbye!\n"); + check = 1; + } + } +} +int main () { + reminders x; + char new; + char *ptrNew = &new; + char aa = 'y'; + int docNum = 0; + int *ptrNum = &docNum; + getWelcome(ptrNew, ptrNum); + if (new == aa) { + getInfo(x, ptrNum); + } + getOptions(x, ptrNum); + return 0; +} From 4791ae983324a5588bafe49e35d5ef1eab1c6b4a Mon Sep 17 00:00:00 2001 From: Bettina Date: Fri, 15 Jul 2016 16:06:57 -0400 Subject: [PATCH 3/3] fixed README --- README.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 0aadfbe..b8278a2 100644 --- a/README.txt +++ b/README.txt @@ -2,4 +2,8 @@ Bettina Benitez My program is a reminders program that lets the user add a reminder. The reminder asks for title, day, time, priority. To use the program, you just have to follow the instructions using abc or 123. -It can add more reminders or retrieve reminders. If you want to end the program, you can press 'c' as it says on the instructions/ +It can add more reminders or retrieve reminders. If you want to end the program, you can press 'c' as it says on the instructions. + +I used a lot of what I have learnt from this class. Such as if statments, pointers, arrays, strings etc. + +However, I did encounter a few bugs. When comparing the string, it did not let me compare the two strings. I actually had problems with comparing strings before but there was something with my code that made it prblematic again. Nevertheless, the code (which returns invalid) should return the reminders and the list of it.