SlideShare a Scribd company logo
1 of 7
Download to read offline
C++ [Submission] - submit the driver program (DvcSchedule1.cpp) and the header files
(StaticArray.h and/or DynamicArray.h) used in the driver program.
Code I wrote:
main:
#include
#include
#include
#include "DynamicArray.h"
using namespace std;
struct Subject
{
string subjectCode;
int count;
};
int main()
{
int counter = 0;
int duplicate = 0;
int course_index = 0;
int subject_index = 0;
bool found = false;
char* token;
char buf[1000];
const char* const tab = "t";
DynamicArray subjectCount(100);
DynamicArray courseCount(100);
ifstream fin;
fin.open("dvc-schedule.txt");
if (!fin.good()) throw "I/O error";
while (fin.good())
{
string line;
getline(fin, line);
strcpy(buf, line.c_str());
if (buf[0] == 0) continue;
const string term(token = strtok(buf, tab));
const string section((token = strtok(0, tab)) ? token : "");
const string course((token = strtok(0, tab)) ? token : "");
const string instructor((token = strtok(0, tab)) ? token : "");
const string whenWhere((token = strtok(0, tab)) ? token : "");
if (course.find('-') == string::npos) continue;
const string subjectCode(course.begin(), course.begin() +
course.find('-'));
found = false;
for (int i = 0; i < course_index; i++)
{
if (courseCount[i] == course)
{
found = true;
duplicate++;
break;
}
}
if (!found)
{
courseCount[course_index] = course;
course_index++;
}
found = false;
for (int i = 0; i < subject_index; i++)
{
if (subjectCount[i].subjectCode == subjectCode)
{
subjectCount[i].count++;
found = true;
break;
}
}
if (!found)
{
subjectCount[subject_index].subjectCode = subjectCode;
subjectCount[subject_index].count = 1;
subject_index++;
}
if (counter % 1000 == 1) cout << '.';
cout.flush();
counter++;
}
cout << endl << endl;
for (int i = 0; i < subject_index; i++)
{
cout << subjectCount[i].subjectCode << ", " << subjectCount[i].count << "
sections" << endl;
}
cout << "nDuplicates: " << duplicate << endl;
}
Header:
#ifndef DynamicArray_h
#define DynamicArray_h
#include
using namespace std;
template
class DynamicArray
{
int cap;
T* values;
T dummy;
public:
DynamicArray(int = 2);
~DynamicArray() { delete[] values; }
DynamicArray(const DynamicArray&);
int capacity() const { return cap; }
T operator[](int) const;
T& operator[](int);
DynamicArray& operator=(const DynamicArray&);
void capacity(int);
};
template
DynamicArray::DynamicArray(int cap)
{
this->cap = cap;
values = new T[cap];
for (int i = 0; i < capacity(); i++)
values[i] = T();
}
template
DynamicArray::DynamicArray(const DynamicArray& original)
{
cap = original.cap;
values = new T[cap];
for (int i = 0; i < cap; ++i)
values[i] = original.values[i];
}
template
T DynamicArray::operator[](int index) const
{
if (index < 0) return dummy;
if (index >= cap) return dummy;
return values[index];
}
template
T& DynamicArray::operator[](int index)
{
if (index < 0) return dummy;
if (index >= cap) capacity(2 * index);
return values[index];
}
template
DynamicArray& DynamicArray::operator=(const DynamicArray& original)
{
if (this != &original)
{
delete [] values;
cap = original.cap;
values = new T[cap];
for (int i = 0; i < cap; i++)
values[i] = original.values[i];
}
return *this;
}
template
void DynamicArray::capacity(int cap)
{
T* temp = new T[cap];
int limit = min(cap, this->cap);
for (int i = 0; i < limit; i++)
temp[i] = values[i];
for (int i = limit; i < cap; i++)
temp[i] = T();
delete [] values;
values = temp;
this->cap = cap;
}
#endif
found = false; for (int i=0;i< course_index; i++) { if (courseCount[i] == course) { found = true;
duplicate++; break; } } if (!found) { courseCount [course_index] = course; course_index++; }
67 68 found false:
Applying A Data Structure To A Big Data Application [ DvcScheduleV1.cpp and StaticArray.h,
or DynamicArray.h] In this programming assignment you will have your first experience with
manipulating big data. The data is extracted from the DVC database of all class sections offered
at DVC since the Fall 2001 semester. 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 DvcScheduleV1.cpp to read and parse more than
100,000 line dvc-schedule.txt text file (6 MB), ignore the duplicated sections (by checking the
classcode- term with the section number), and find each subject code in the file. Output each
code to the console screen, in
alphabeticalorder,withthenumberofclassesofferedunderthatcode.Use your StaticArray template
and (or) DynamicArray template from the previous Assignments and 1-D arrays only. Do NOT
use any STL containers, and do NOT modify your H except to make corrections. Submit the H
file, even if there are no corrections since Assignment 3. Canvas will add it's version tracking to
the file's name -- that's okay. NOTE: The dvc-schedule.txt file is expected to be in the working
folder. In command line compiling, that's the same folder as the CPP and H files. In IDEs, you'll
have to figure out for your IDE and project where is the working folder. Do not submit work that
has a path designation in the file-open statement. Note -- the dvc-schedule.txt file may contain
duplicate entries. The combination of a term and section number is supposed to be unique. A
duplicate entry is when the same term and section number pair appear in more than one record.
Do NOT count duplicates -- skip them. That means to count a duplicate entry only once, ignoring
all others. You'll need some way to track what's been counted so that you don't count the same
section for the same semester more than once. When you are done processing the input file,
output HOW MANY DUPLICATES you found and skipped in the input file. Check that number
with your classmates, because you should all come up with the same number. You may use the
Q&A section of this module for that. You can expect the runtime to be several minutes. So that
you don't stare at a blinking cursor while you wait for results, add a "progress bar". To do so,
count the number of lines read from the file. For every 1000 lines read, output a dot -- like this:
cout '.'; cout.flush( ); No endl. You need cout.flush(); to force output out of the output buffer and
onto the console. After the EOF loop ends, output an endl, so that your output starts on a line
after the line of dots. Or use some other method of indicating progress, as you prefer, but
whatever you do, do not forget to flush! Don't get this sent back for redo simply for forgetting
this! Follow the algorithm developed in the lecture to solve this. 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.
1. Parse. Start with the simple parsing code and see if you can read and parse the TXT file. 2.
Count. Then add your code to count how many subject codes and how many sections of each. 3.
Duplicate Check. Then add your code to track and exclude duplicates from counting. If you do
this right there should be a loop with a code block (or series of code blocks) that read and parse a
line of input, then a code block (or series of code blocks) that check and reject duplicates, then a
code block (or series of code blocks) that count. These three separate groups of code blocks
should NOT overlap. They should each do their own job. [Submission] - submit the driver
program (DvcSchedule1.cpp) and the header files (StaticArray.h and/or DynamicArray.h) used
in the driver program.

More Related Content

Similar to C++ [Submission] - submit the driver program (DvcSchedule1.cpp) and .pdf

Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfrajeshjangid1865
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVAMuskanSony
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)SURBHI SAROHA
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabvikrammutneja1
 
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdfBackground Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdfebrahimbadushata00
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++TemplatesGanesh Samarthyam
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingMax Kleiner
 
Intro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysIntro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysBlue Elephant Consulting
 

Similar to C++ [Submission] - submit the driver program (DvcSchedule1.cpp) and .pdf (20)

C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Bt0065
Bt0065Bt0065
Bt0065
 
B T0065
B T0065B T0065
B T0065
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdf
 
Input-output
Input-outputInput-output
Input-output
 
C language tutorial
C language tutorialC language tutorial
C language tutorial
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVA
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Functions
FunctionsFunctions
Functions
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdfBackground Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
 
Function in c program
Function in c programFunction in c program
Function in c program
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++Templates
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
 
Intro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysIntro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & Arrays
 

More from rahulfancycorner21

Consider a world in which there are two nations � the US and China, ea.pdf
Consider a world in which there are two nations � the US and China, ea.pdfConsider a world in which there are two nations � the US and China, ea.pdf
Consider a world in which there are two nations � the US and China, ea.pdfrahulfancycorner21
 
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdf
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdfConfigure iptables to ACCEPT packets by defaultConfigure iptables .pdf
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdfrahulfancycorner21
 
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdf
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdfCIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdf
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdfrahulfancycorner21
 
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdf
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdfCLIENT APPLICATION Create a standalone, interactive, and fully com.pdf
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdfrahulfancycorner21
 
Case Study Makati CityMakati City is one of the sixteen cit.pdf
Case Study Makati CityMakati City is one of the sixteen cit.pdfCase Study Makati CityMakati City is one of the sixteen cit.pdf
Case Study Makati CityMakati City is one of the sixteen cit.pdfrahulfancycorner21
 
Clara fears she may have made a mistake in how she handled the expen.pdf
Clara fears she may have made a mistake in how she handled the expen.pdfClara fears she may have made a mistake in how she handled the expen.pdf
Clara fears she may have made a mistake in how she handled the expen.pdfrahulfancycorner21
 
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdf
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdfChapter 11 Conrols for Information Security11.4 Which preventive, .pdf
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdfrahulfancycorner21
 
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdf
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdfCase 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdf
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdfrahulfancycorner21
 
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdf
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdfCASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdf
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdfrahulfancycorner21
 
can i have the Answers of the above questions 1. Compare and contr.pdf
can i have the Answers of the above questions 1. Compare and contr.pdfcan i have the Answers of the above questions 1. Compare and contr.pdf
can i have the Answers of the above questions 1. Compare and contr.pdfrahulfancycorner21
 
Case 1 Why shareholders wealth maximization value maximization is c.pdf
Case 1 Why shareholders wealth maximization value maximization is c.pdfCase 1 Why shareholders wealth maximization value maximization is c.pdf
Case 1 Why shareholders wealth maximization value maximization is c.pdfrahulfancycorner21
 
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdf
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdfCapstone Project E-Commerce Application with Firebase Firestore Obj.pdf
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdfrahulfancycorner21
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdfrahulfancycorner21
 
Can you draw a database design Entity relationship ERand the rela.pdf
Can you draw a database design Entity relationship ERand the rela.pdfCan you draw a database design Entity relationship ERand the rela.pdf
Can you draw a database design Entity relationship ERand the rela.pdfrahulfancycorner21
 
Business PlanA business plan is any simple plan, not only limited .pdf
Business PlanA business plan is any simple plan, not only limited .pdfBusiness PlanA business plan is any simple plan, not only limited .pdf
Business PlanA business plan is any simple plan, not only limited .pdfrahulfancycorner21
 
Can we please draw this BPM process roughly on paper and post a pict.pdf
Can we please draw this BPM process roughly on paper and post a pict.pdfCan we please draw this BPM process roughly on paper and post a pict.pdf
Can we please draw this BPM process roughly on paper and post a pict.pdfrahulfancycorner21
 
Can we draw this BPM on paper showing shapes arrows and connectors .pdf
Can we draw this BPM on paper showing shapes arrows and connectors .pdfCan we draw this BPM on paper showing shapes arrows and connectors .pdf
Can we draw this BPM on paper showing shapes arrows and connectors .pdfrahulfancycorner21
 
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdf
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdfCan u give a CORAS ASSEST DIAGRAM for the following case study - The.pdf
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdfrahulfancycorner21
 
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfrahulfancycorner21
 
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdf
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdfBUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdf
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdfrahulfancycorner21
 

More from rahulfancycorner21 (20)

Consider a world in which there are two nations � the US and China, ea.pdf
Consider a world in which there are two nations � the US and China, ea.pdfConsider a world in which there are two nations � the US and China, ea.pdf
Consider a world in which there are two nations � the US and China, ea.pdf
 
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdf
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdfConfigure iptables to ACCEPT packets by defaultConfigure iptables .pdf
Configure iptables to ACCEPT packets by defaultConfigure iptables .pdf
 
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdf
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdfCIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdf
CIS611 SS Chung Lab Assignment 2 Implementing Big Data Processing Pipe.pdf
 
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdf
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdfCLIENT APPLICATION Create a standalone, interactive, and fully com.pdf
CLIENT APPLICATION Create a standalone, interactive, and fully com.pdf
 
Case Study Makati CityMakati City is one of the sixteen cit.pdf
Case Study Makati CityMakati City is one of the sixteen cit.pdfCase Study Makati CityMakati City is one of the sixteen cit.pdf
Case Study Makati CityMakati City is one of the sixteen cit.pdf
 
Clara fears she may have made a mistake in how she handled the expen.pdf
Clara fears she may have made a mistake in how she handled the expen.pdfClara fears she may have made a mistake in how she handled the expen.pdf
Clara fears she may have made a mistake in how she handled the expen.pdf
 
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdf
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdfChapter 11 Conrols for Information Security11.4 Which preventive, .pdf
Chapter 11 Conrols for Information Security11.4 Which preventive, .pdf
 
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdf
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdfCase 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdf
Case 12�1Carson ManorIn late November, Ms. Elaine Taylor, direct.pdf
 
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdf
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdfCASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdf
CASE STUDY 1 Alternative Water Supply Gordon Rivers, the city manage.pdf
 
can i have the Answers of the above questions 1. Compare and contr.pdf
can i have the Answers of the above questions 1. Compare and contr.pdfcan i have the Answers of the above questions 1. Compare and contr.pdf
can i have the Answers of the above questions 1. Compare and contr.pdf
 
Case 1 Why shareholders wealth maximization value maximization is c.pdf
Case 1 Why shareholders wealth maximization value maximization is c.pdfCase 1 Why shareholders wealth maximization value maximization is c.pdf
Case 1 Why shareholders wealth maximization value maximization is c.pdf
 
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdf
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdfCapstone Project E-Commerce Application with Firebase Firestore Obj.pdf
Capstone Project E-Commerce Application with Firebase Firestore Obj.pdf
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
 
Can you draw a database design Entity relationship ERand the rela.pdf
Can you draw a database design Entity relationship ERand the rela.pdfCan you draw a database design Entity relationship ERand the rela.pdf
Can you draw a database design Entity relationship ERand the rela.pdf
 
Business PlanA business plan is any simple plan, not only limited .pdf
Business PlanA business plan is any simple plan, not only limited .pdfBusiness PlanA business plan is any simple plan, not only limited .pdf
Business PlanA business plan is any simple plan, not only limited .pdf
 
Can we please draw this BPM process roughly on paper and post a pict.pdf
Can we please draw this BPM process roughly on paper and post a pict.pdfCan we please draw this BPM process roughly on paper and post a pict.pdf
Can we please draw this BPM process roughly on paper and post a pict.pdf
 
Can we draw this BPM on paper showing shapes arrows and connectors .pdf
Can we draw this BPM on paper showing shapes arrows and connectors .pdfCan we draw this BPM on paper showing shapes arrows and connectors .pdf
Can we draw this BPM on paper showing shapes arrows and connectors .pdf
 
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdf
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdfCan u give a CORAS ASSEST DIAGRAM for the following case study - The.pdf
Can u give a CORAS ASSEST DIAGRAM for the following case study - The.pdf
 
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
 
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdf
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdfBUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdf
BUsiness law9.3 Implied-in-Fact Contract For six years, Lee Marvin.pdf
 

Recently uploaded

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 

Recently uploaded (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 

C++ [Submission] - submit the driver program (DvcSchedule1.cpp) and .pdf

  • 1. C++ [Submission] - submit the driver program (DvcSchedule1.cpp) and the header files (StaticArray.h and/or DynamicArray.h) used in the driver program. Code I wrote: main: #include #include #include #include "DynamicArray.h" using namespace std; struct Subject { string subjectCode; int count; }; int main() { int counter = 0; int duplicate = 0; int course_index = 0; int subject_index = 0; bool found = false; char* token; char buf[1000]; const char* const tab = "t"; DynamicArray subjectCount(100); DynamicArray courseCount(100); ifstream fin; fin.open("dvc-schedule.txt"); if (!fin.good()) throw "I/O error"; while (fin.good()) { string line; getline(fin, line); strcpy(buf, line.c_str());
  • 2. if (buf[0] == 0) continue; const string term(token = strtok(buf, tab)); const string section((token = strtok(0, tab)) ? token : ""); const string course((token = strtok(0, tab)) ? token : ""); const string instructor((token = strtok(0, tab)) ? token : ""); const string whenWhere((token = strtok(0, tab)) ? token : ""); if (course.find('-') == string::npos) continue; const string subjectCode(course.begin(), course.begin() + course.find('-')); found = false; for (int i = 0; i < course_index; i++) { if (courseCount[i] == course) { found = true; duplicate++; break; } } if (!found) { courseCount[course_index] = course; course_index++; } found = false; for (int i = 0; i < subject_index; i++) { if (subjectCount[i].subjectCode == subjectCode) { subjectCount[i].count++; found = true; break; } }
  • 3. if (!found) { subjectCount[subject_index].subjectCode = subjectCode; subjectCount[subject_index].count = 1; subject_index++; } if (counter % 1000 == 1) cout << '.'; cout.flush(); counter++; } cout << endl << endl; for (int i = 0; i < subject_index; i++) { cout << subjectCount[i].subjectCode << ", " << subjectCount[i].count << " sections" << endl; } cout << "nDuplicates: " << duplicate << endl; } Header: #ifndef DynamicArray_h #define DynamicArray_h #include using namespace std; template class DynamicArray { int cap; T* values; T dummy; public: DynamicArray(int = 2); ~DynamicArray() { delete[] values; } DynamicArray(const DynamicArray&); int capacity() const { return cap; } T operator[](int) const; T& operator[](int);
  • 4. DynamicArray& operator=(const DynamicArray&); void capacity(int); }; template DynamicArray::DynamicArray(int cap) { this->cap = cap; values = new T[cap]; for (int i = 0; i < capacity(); i++) values[i] = T(); } template DynamicArray::DynamicArray(const DynamicArray& original) { cap = original.cap; values = new T[cap]; for (int i = 0; i < cap; ++i) values[i] = original.values[i]; } template T DynamicArray::operator[](int index) const { if (index < 0) return dummy; if (index >= cap) return dummy; return values[index]; } template T& DynamicArray::operator[](int index) { if (index < 0) return dummy; if (index >= cap) capacity(2 * index); return values[index]; } template
  • 5. DynamicArray& DynamicArray::operator=(const DynamicArray& original) { if (this != &original) { delete [] values; cap = original.cap; values = new T[cap]; for (int i = 0; i < cap; i++) values[i] = original.values[i]; } return *this; } template void DynamicArray::capacity(int cap) { T* temp = new T[cap]; int limit = min(cap, this->cap); for (int i = 0; i < limit; i++) temp[i] = values[i]; for (int i = limit; i < cap; i++) temp[i] = T(); delete [] values; values = temp; this->cap = cap; } #endif found = false; for (int i=0;i< course_index; i++) { if (courseCount[i] == course) { found = true; duplicate++; break; } } if (!found) { courseCount [course_index] = course; course_index++; } 67 68 found false: Applying A Data Structure To A Big Data Application [ DvcScheduleV1.cpp and StaticArray.h, or DynamicArray.h] In this programming assignment you will have your first experience with manipulating big data. The data is extracted from the DVC database of all class sections offered at DVC since the Fall 2001 semester. 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.,
  • 6. MATH, 4514 classes). Requirements. Write DvcScheduleV1.cpp to read and parse more than 100,000 line dvc-schedule.txt text file (6 MB), ignore the duplicated sections (by checking the classcode- term with the section number), and find each subject code in the file. Output each code to the console screen, in alphabeticalorder,withthenumberofclassesofferedunderthatcode.Use your StaticArray template and (or) DynamicArray template from the previous Assignments and 1-D arrays only. Do NOT use any STL containers, and do NOT modify your H except to make corrections. Submit the H file, even if there are no corrections since Assignment 3. Canvas will add it's version tracking to the file's name -- that's okay. NOTE: The dvc-schedule.txt file is expected to be in the working folder. In command line compiling, that's the same folder as the CPP and H files. In IDEs, you'll have to figure out for your IDE and project where is the working folder. Do not submit work that has a path designation in the file-open statement. Note -- the dvc-schedule.txt file may contain duplicate entries. The combination of a term and section number is supposed to be unique. A duplicate entry is when the same term and section number pair appear in more than one record. Do NOT count duplicates -- skip them. That means to count a duplicate entry only once, ignoring all others. You'll need some way to track what's been counted so that you don't count the same section for the same semester more than once. When you are done processing the input file, output HOW MANY DUPLICATES you found and skipped in the input file. Check that number with your classmates, because you should all come up with the same number. You may use the Q&A section of this module for that. You can expect the runtime to be several minutes. So that you don't stare at a blinking cursor while you wait for results, add a "progress bar". To do so, count the number of lines read from the file. For every 1000 lines read, output a dot -- like this: cout '.'; cout.flush( ); No endl. You need cout.flush(); to force output out of the output buffer and onto the console. After the EOF loop ends, output an endl, so that your output starts on a line after the line of dots. Or use some other method of indicating progress, as you prefer, but whatever you do, do not forget to flush! Don't get this sent back for redo simply for forgetting this! Follow the algorithm developed in the lecture to solve this. 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. 1. Parse. Start with the simple parsing code and see if you can read and parse the TXT file. 2. Count. Then add your code to count how many subject codes and how many sections of each. 3. Duplicate Check. Then add your code to track and exclude duplicates from counting. If you do this right there should be a loop with a code block (or series of code blocks) that read and parse a
  • 7. line of input, then a code block (or series of code blocks) that check and reject duplicates, then a code block (or series of code blocks) that count. These three separate groups of code blocks should NOT overlap. They should each do their own job. [Submission] - submit the driver program (DvcSchedule1.cpp) and the header files (StaticArray.h and/or DynamicArray.h) used in the driver program.