1. Homepage
  2. Programming
  3. CMPT 125 Intro. To Computing Science & Programming II - Assignment 3: Talklib

CMPT 125 Intro. To Computing Science & Programming II - Assignment 3: Talklib

Engage in a Conversation
SFUCMPT 125CMPT125Intro. To Computing Science & Programming IICTalklib

Assignment 3 CMPT 125 Intro. To Computing Science & Programming II Fall 2023 CourseNana.COM

Assignment 3 (10% of Course Total) CourseNana.COM

Due date: 11:59pm, Nov 10, 2023 CourseNana.COM

At least part of the assignment will be graded automatically. Make sure that your code compiles without warnings/errors and produces the required output. Also use the file names and structures indicated as requested. Deviation from that might result in 0 mark. CourseNana.COM

Your code MUST compile and run reasonably efficiently in the CSIL machines with the Makefile provided. It is possible that even with warnings your code would compile. But this still indicates there is something wrong with you code and you have to fix them, or marks will be deducted. CourseNana.COM

Your code MUST be readable and have reasonable documentation (comments) explaining what it does. Use your own judgement, for example, no need to explain i += 2 is increasing i by 2, but explain how variables are used to achieve something, what a certain loop is doing, and the purpose of each #include. CourseNana.COM

Description CourseNana.COM

There is only 1 question in this assignment. However, there are several files you need to submit. Write your answer in the corresponding file as instructed along with your student information. You can include any libraries that are covered in class (i.e., stdio, stdlib, string, math, stdbool). You can also write your own helper functions. Only one of these files should contain the main function. CourseNana.COM

Question 1 [16 marks] CourseNana.COM

In this question you are going to extend the program you made in Assignment 2 by providing more functionalities. You are again going to write your own main function so the program runs. CourseNana.COM

Create a program that reads all the talk information from a file and provide an interface for the user to query talk entries. Your program must support the following functionalities as options: CourseNana.COM

  • Option 1: to load a talks file ask the user to input the name of the file containing talk information and load the entries from that file (report # of entries). Note that the file can be non-existent (if so the program should print the error and keep running), but if it exists you can assume the format inside that file is consistent (duration, talk title, overview, ---), with each line having at most 300 characters. It is possible for the user to load a different file by choosing this option again, which will replace the previously loaded entries. You can assume the filename as at most 50 characters. CourseNana.COM

  • Option 2: to list talks sorted by duration list the talk entries from shortest to longest. If with the same duration there are more than one talk entry, any order within that duration is acceptable. CourseNana.COM

  • Option 3: to list talks sorted by title list the talk entries sorted by title (as determined by strcmp). If with the same title there are more than one talk entry, any order within that title is acceptable. CourseNana.COM

  • Option 4: to lookup a talk ask the user for a talk title for at most 50 characters (space included), then report all entries containing the input as a substring. There can be more than one entry from CourseNana.COM

    the file. The lookup is case-sensitive (i.e., computerand Computerare not the same). CourseNana.COM

o If one or more entries are found, print all the information. Any order is acceptable. o If no entry is found, print “No such talk on record.” CourseNana.COM

You can assume the user will always enter at most 50 characters.
Option 5: to terminate the program thank the user and end the program. CourseNana.COM

Your program must meet these requirements: CourseNana.COM

  • Include the provided header file (.h file) and use the functions defined in the corresponding implementation file (.c file) in your driver file (where main is), do not redefine those functions. CourseNana.COM

  • Use a dynamic array of Talk struct pointers to store the talk information. This is the recommended approach (instead of a static array with a fixed size) as we might change the number of entries in the provided file, and dynamic arrays can accommodate that variation. CourseNana.COM

  • There must be no memory leaks (e.g., your program requests some memory but does not release them all before it terminates). In CSIL you can use the Valgrind tool as described to check for that. CourseNana.COM

  • Start with a fancy banner. There is no specific requirement besides it must include your name, 9- CourseNana.COM

    digit SFU ID, and your SFU email address. Let your creativity shine, just nothing offensive. CourseNana.COM

  • If a functionality (e.g., list, lookup) is requested by the user but no file has been loaded, the program should print an error message telling the user that no talks file have been loaded and CourseNana.COM

    prompt the user to do so. CourseNana.COM

  • The sorting for Options 2&3 must be done using the built-in qsort. Meaning you have to write CourseNana.COM

    your own compare functions for qsort to use (see a3_talklib.h and a3_talklib.c). And here are some hints for you to write your code: CourseNana.COM

  • The interface is essentially a do-while loop where in each iteration it asks for an option and determines what to do, with a repeating conditional of the terminating option has not been inputted. It is a common approach for menu-based interfaces. CourseNana.COM

  • Since each item in the dynamic array for the talk entries are pointers, be careful with how you are casting the pointer variables in the compare functions (they are pointers to the items) suppose the dynamic array has the type Talk**, then the variables should be cast to Talk**. CourseNana.COM

  • The scanf() function works slightly differently between different formats. One difference is how it handles leading and trailing newlines (look up “dangling newline character” if you are curious). One option to get around this is put a space in front of the format string (e.g., “ %d”, “ %s”). You are encouraged to explore different ways to get around this issue. CourseNana.COM

    *The entries are randomly generated using ChatGPT with a specific format and then lightly modified. Hence, the content might not make sense and have very similar wording patterns no need to worry. CourseNana.COM

    Include the function definitions corresponding to a3_talklib.h (and your helper functions, if any) in a source file named as a3_talklib.c. Remember the .h file declares the functions and the .c file define them. CourseNana.COM

    Include your main function (and your helper functions, if any) in another source file named as a3_talkLookupSystem.c. We call this the driver file because this is where the program starts. CourseNana.COM

    To determine where to place a helper function, think about its purpose. If it provides functionality with the Talk structs (e.g., create/clear Talks, compare Talks), it is a library function; if it provides functionality of the program (e.g., print a fancy banner), it is a program function. Incorrectly placing these functions will lead to mark deductions in the Coding Style category. CourseNana.COM

Coding Style [4 marks] CourseNana.COM

Your program should be properly indented, have clear and meaningful variable names (e.g., no single- letter variable names except loop iterators) and enough white space and comments to make it easy to read. Named constants should be used where appropriate. Each line of code should not exceed 80 characters. White space should be used in a consistent manner. CourseNana.COM

Keep your code concise and efficient. If your code is unnecessarily long or inefficient (e.g., hard-code for all possible cases, extraneous function calls), we might deduct marks. To help you to get into the habit of good coding style, we will read your code and marks will be deducted if your code is not styled properly. CourseNana.COM

Using the Makefile and Other Supplied Files CourseNana.COM

The Makefile provided in this assignment is used by a command in the CSIL machines called “make” to quickly compile your code. It is especially useful if you have multiple source files. To use it, type the following command in the prompt (make sure you are in the directory with all the files of Assignment 3): CourseNana.COM

$ make test1 CourseNana.COM

The example above illustrates how Question 1 is compiled into an executable called “test1” when using the Makefile. Replace the “test1” with “test2”, “test3”, ...etc. for other questions. You can then run the executable by typing “./test1” to test your code for Question 1. If you make changes to your code, use the make command again. You can also use “make all” if you want to compile all your code at once. CourseNana.COM

The header file a3_talklib.h is there to make the compilation work. Take a look at it for information about how each function should work. You might have to modify it and you will have to submit it this time. CourseNana.COM

Submission CourseNana.COM

Submit only the 3 source files (a3_talklib.h, a3_talklib.c, a3_talkLookupSystem.c) to CourSys. Refer to the corresponding Canvas assignment entry for details. CourseNana.COM

Assignment late penalty: 10% per calendar day (each 0 to 24 hour period past due), max 2 days late. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
SFU代写,CMPT 125代写,CMPT125代写,Intro. To Computing Science & Programming II代写,C代写,Talklib代写,SFU代编,CMPT 125代编,CMPT125代编,Intro. To Computing Science & Programming II代编,C代编,Talklib代编,SFU代考,CMPT 125代考,CMPT125代考,Intro. To Computing Science & Programming II代考,C代考,Talklib代考,SFUhelp,CMPT 125help,CMPT125help,Intro. To Computing Science & Programming IIhelp,Chelp,Talklibhelp,SFU作业代写,CMPT 125作业代写,CMPT125作业代写,Intro. To Computing Science & Programming II作业代写,C作业代写,Talklib作业代写,SFU编程代写,CMPT 125编程代写,CMPT125编程代写,Intro. To Computing Science & Programming II编程代写,C编程代写,Talklib编程代写,SFUprogramming help,CMPT 125programming help,CMPT125programming help,Intro. To Computing Science & Programming IIprogramming help,Cprogramming help,Talklibprogramming help,SFUassignment help,CMPT 125assignment help,CMPT125assignment help,Intro. To Computing Science & Programming IIassignment help,Cassignment help,Talklibassignment help,SFUsolution,CMPT 125solution,CMPT125solution,Intro. To Computing Science & Programming IIsolution,Csolution,Talklibsolution,