The purpose of this project is for students to demonstrate a working knowledge of data structures for solving real-life problems. Real-life solutions have to be programmed quickly and they have to execute fast. There are three such solutions that you will develop here.
Maps are "dictionaries" that store key-value pairs, retrievable knowing only the key. Maps support iteration, and in doing so, they return values in order according to the key values.
This time, the program is to take full advantage of the STL map template, and include nothing that is not required when applying the map. That means no structs, no STL pairs, and no sorting, because they are all not necessary.
Mark Twain is credited with this quote: "If I'd had more time, I would have written a shorter letter". Writing the term project program is the same way -- if you plan carefully and use the full power of the STL, you can solve this in the shortest amount of code. The result should be an elegant solution to the problem, with a lot less code than was used in previous DVC schedule parsers written for this course.
Here are the requirements for the two-part project:
REQUIREMENTS (Part 1 of 3)
Write the final version of DvcSchedule.
Rewrite DvcSchedule6b.cpp from lab 6, renaming it as DvcScheduleFinal.cpp.
As in lab 6, parse the dvc-schedule.txt file, located in your working directory.
As in lab 6, include NO user input except an optional "press ENTER to continue" at the end if you so wish -- do NOT prompt for the input file name or anything else.
Unlike lab 6, do NOT output an Excel xls file.
Use only the STL map, set, and pair templates and their iterators -- no other data structures or STL algorithms.
Do NOT use programmer-written structs or classes (unlike lab 6).
The program should be short enough to fit fully in main -- no functions (except for identifying couts).
Code blocks should be labeled with comments, and the programming should be well-organized and professional in its appearance.
Including normal code block spacing and commenting, and without multiple statements on single lines, the whole solution should be less than 80 lines of code, not counting your identifying comments and couts, and not counting blank lines.
The program should read its input file and execute, all in less than one second (on a classroom PC), before its output begins to appear on the screen.
The format of the output should be the same as for the lab 6 version.
Remember to skip duplicate section-term entries.
REQUIREMENTS (Part 2 of 3)
Each section-term combination is supposed to be unique -- that is, there should never be two separate entries with the same section and term, but with different course names.
Write DvcScheduleCheck.cpp to solve the problem. Output how many term-section pairs there are with multiple courses associated with them. If there are none, output a message to that effect. But if there are any, output them in a format that you think DVC Admissions could understand.
REQUIREMENTS (Part 3 of 3)
College catalogs sometimes list courses that have not been offered in many years, and departments have no intention of offering them again. It's a disservice to students and to the community to continue to list them. For this (and several other reasons) the administration wants a program that will tell the last semester in which a course was offered.
Write DvcScheduleSearch.cpp to solve the problem. In a loop, prompt the user to enter a course name (like COMSC-210) including a subject code (like COMSC), a dash, and an alphanumeric sequence number. If a user enters uppercase or lowercase X, quit the loop and the program -- be sure to explain this in the prompt. For any other input, look up the course and output the last time that course was offered, nicely labeled (like "COMSC-210 was last offered in Fall 2014"). Or if the course is not found, output something like this: "CS=1000 has not been offered since the year 2000" because that's as far back as the database goes.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.// Project, "Using maps"
// Programmer :
// Editor(s) used : Win7 notepad
// Compiler used : VC++ 2010 Professional
using namespace std;
// Print at begining
cout<<"Project, Using maps"<<endl;
cout<<"Programmer : Minwhan Oh (1382019)\n";
cout<<"Complied: "<<__DATE__<<" at "<<__TIME__<<endl<<endl;
const char* const tab = "\t";
map<string, map<string, int>> SubjectCode;
clock_t startTime = clock();
if(!fin.good()) throw "I/O error";
count = 0;
// Parsing file
const string term(token = strtok(buf, tab));
const string section(token = strtok(0, tab));
const string course((token = strtok(0, tab)) ? token : "");
const string instructor...