In this lab you will have your first experience with manipulating records from a
ID: 3529713 • Letter: I
Question
In this lab you will have your first experience with manipulating records from a database. The database is the list of all class sections offered at DVC in the last 10 years. Your program is to list all of the subject codes (like COMSC, MATH, PHYS, etc), and include for each subject code the count of classes (e.g., MATH, 4514 classes). Requirements. Write DvcSchedule5b.cpp to read a text file, and find each subject code in the file. (Refer to the lecture topic 5 & 6 notes for how to parse this file.) Print each code to the console screen, in alphabetical order, with the number of classes offered under that code. Use either your own Array class template from lab 5a, or the STL vector template, as you wish. Note that if you use your own Array, you may need to have code to expand the array as you read the file and find that there are more lines than you originally sized for. Note -- the *.txt file may contain duplicate entries! Print the program's runtime in decimal seconds, rounded to two decimal digits. You'll need the appropriate C library for the definitions in the following code blocks -- figure that out for yourself. Use this in main BEFORE you open the input file: clock_t startTime = clock(); Use this in main AFTER printing your results: double elapsedSeconds = (double)(clock() - startTime) / CLOCKS_PER_SEC;, and then print elapsedSeconds, properly labeled. Solve this any way you can, but you may wish to use a struct for the elements of the array, with the name and count of a subject code. To get the array in alphabetical order after it is filled, use a simple nested for-loop with compare and swap -- no C qsort or STL sort functions. C++ strings have a compare function that you can use. But use that function correctly, because some compilers do not implement the return value of this function per the C++ standard. Be careful! Don't just accept whatever counts that your program gives you. Make sure that your program gives the right answers for the input file used. Try using a much shortened version of the TXT file, for which you know exactly what to expect. Also try loading the TXT file into Excel -- sort the data in column A, and count for yourself to verify the results of your app. HINT: If your program seems to run an extraordinarily long time (i.e., minutes) then make sure you are not storing every line of the input file. The supplied input file has over 50,000 lines, but there are only about 100 different subject codes in those lines. You should be storing 100 or so objects of the SubjectCode struct -- not 50,000. Before adding a new SubjectCode, check to see if there already is a matching SubjectCode name, and if so, just add one to its count. Only add a new SubjectCode with a count of 1 if you find no name match in what you have already stored. Submit the CPP file to the class website for credit. If you used your own Array template, there is no need to submit anything other than what you submitted already for lab 5a. Do NOT submit the very large input TXT file.Explanation / Answer
What is ur question comment in my answer
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.