Question
*****Gettting these error messages when running this programming**** Running /home/ec2-user/environment/Assignment6/LabExercise6.cpp /home/ec2-user/environment/Assignment6/LabExercise6.cpp:35:8: error: expected constructor, destructor, or type conversion before '(' token exists (Return->Yes: index, No:
*****Gettting these error messages when running this programming****
Running /home/ec2-user/environment/Assignment6/LabExercise6.cpp
/home/ec2-user/environment/Assignment6/LabExercise6.cpp:35:8: error: expected constructor, destructor, or type conversion before '(' token
exists (Return->Yes: index, No: -1)
^
/home/ec2-user/environment/Assignment6/LabExercise6.cpp:37:1: error: 'number' does not name a type
number is seen (Return->true/false)
^~~~~~
/home/ec2-user/environment/Assignment6/LabExercise6.cpp: In function 'int main()':
/home/ec2-user/environment/Assignment6/LabExercise6.cpp:113:5: error: 'IDCheck' was not declared in this scope
if(IDCheck(terms, index, cur))
^~~~~~~
/home/ec2-user/environment/Assignment6/LabExercise6.cpp:113:5: note: suggested alternative: 'TermCheck'
if(IDCheck(terms, index, cur))
^~~~~~~
TermCheck
sortSubjects(subjects, num_subjects);
^~~~~~~~~~~~
/home/ec2-user/environment/Assignment6/LabExercise6.cpp:143:2: note: suggested alternative: 'subjects'
sortSubjects(subjects, num_subjects);
^~~~~~~~~~~~
subjects
*******Program is this********
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
using namespace std;
#include
#include "DynamicArray.h"
#include "StaticArray.h"
struct Term
{
string name;
int num_IDs; //for track the number of IDs seen
DynamicArray
};
struct ClassInfo
{
string term;
string section;
string course;
string professor;
string meetingInfo;
string subject;
};
struct Subject
{
string name;
int count;
};
//Function Prottypes
int TermCheck(StaticArray
exists (Return->Yes: index, No: -1)
bool IDCheck(StaticArray
number is seen (Return->true/false)
void sortSubjects(DynamicArray
int main()
{
// programmer's identification
cout << "Programmer: Saleem Ghafoori ";
cout << "Programmer's ID: 1793656 ";
cout << "File: " << __FILE__ << endl << endl;
StaticArray
DynamicArray
int num_terms = 0;
int num_lines = 0;
int num_duplicates = 0;
int num_subjects = 0;
char* token;
char buf[1000];
const char* const tab = "\t";
// open file
ifstream fin;
fin.open("dvc-schedule.txt");
// fin.open("test.txt");
if (!fin.good())
cout << "I/O error ";
//read file line by line until EOF
while (fin.good())
{
ClassInfo cur;
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 prof((token = strtok(0, tab)) ? token : "");
const string meetingInfo((token = strtok(0, tab)) ? token : "");
if (course.find('-') == string::npos) continue;
const string subject(course.begin(), course.begin() + course.find('-'));
//count how many eligible lines parsed
num_lines++;
//display "#" every 1000 lines
if(num_lines%1000 == 0)
{
cout << '#';
cout.flush( );
}
//Aggregate the input data into a ClassInfo object
cur.term = term;
cur.section = section;
cur.course = course;
cur.professor = prof;
cur.meetingInfo = meetingInfo;
cur.subject = subject;
//Duplication Check
//1.Check if the term is alrady seen
//2.If yes, check if the section is seen in the term
//If the term is not found, return -1
if(TermCheck(terms, num_terms, cur) == -1)
{
terms[num_terms].num_IDs = 0;
terms[num_terms].name = cur.term;
terms[num_terms].ID[terms[num_terms].num_IDs++] = cur.section;
num_terms++;
}
//If the term is found, return the index
else
{
int index = TermCheck(terms, num_terms, cur);
//Return true if the ID is found in the array
if(IDCheck(terms, index, cur))
{
num_duplicates++;
continue;
}
else
{
terms[index].ID[terms[index].num_IDs++] = cur.section;
}
}
//store subject name to array
int s = 0;
for(s = 0; s < num_subjects; s++)
{
if(subjects[s].name == cur.subject)
{
subjects[s].count++;
break;
}
}
if(s == num_subjects)
{
subjects[num_subjects++] = {cur.subject, 1};
}
}
fin.close();
//sort the subject array alphabetically
sortSubjects(subjects, num_subjects);
cout << endl;
for(int s = 0; s < num_subjects; s++)
cout << subjects[s].name << ":\t" << subjects[s].count << " sections" << endl;
cout << " Total lines: " << num_lines << endl;
cout << "Total Duplicated Data: " << num_duplicates << endl;
cout << "Total subjects: " << num_subjects;
}
int TermCheck(StaticArray
{
for(int i=0; i < num_terms; i++)
{
if(terms[i].name == curClass.term)
{
return i;
}
}
return -1;
}
bool IDCheck(StaticArray
{
for(int i=0; i < terms[index].num_IDs; i++)
{
if(terms[index].ID[i] == curClass.section)
return true;
}
return false;
}
void sortSubjects(DynamicArray
{
Subject tmp;
for(int i = 0; i < num_subjects; ++i)
{
for(int j = i + 1; j < num_subjects; ++j)
{
if (subjects[i].name > subjects[j].name)
{
tmp = subjects[i];
subjects[i] = subjects[j];
subjects[j] = tmp;
}
}
}
}
******DynamicArray.h*******
#ifndef DYNAMICARRAY_H_INCLUDED
#define DYNAMICARRAY_H_INCLUDED
template
class DynamicArray
{
V* values;
int cap;
V dummy = V();
public:
DynamicArray(int = 2);//constructor //default = 2
DynamicArray(const DynamicArray
~DynamicArray(){delete[] values;}//destructor
DynamicArray& operator=(const DynamicArray
int capacity() const;
void capacity(int); //setter
V operator[](int) const; // getter
V& operator[](int); //setter
};
template
DynamicArray
values = new V[cap];
this->cap = cap;
for(int i = 0 ; i < cap; i++){
values[i] = V();
}
}
template
DynamicArray
cap = original.cap;
values = new V[cap];
for(int i = 0 ; i < cap ; i++){
values[i] = original.values[i];
}
dummy = original.dummy;
}
template
DynamicArray
if(this != &original){
delete[] values;
cap = original.cap;
values = new V[cap];
for(int i = 0 ; i < cap ; i++){
values[i] = original.values[i];
}
dummy = original.dummy;
}
return *this;
}
template
int DynamicArray
return cap;
}
template
void DynamicArray
V* temp = new V[cap];
int limit = (cap < this->cap) ? cap: this->cap;
for(int i = 0 ; i < limit ; i++){
temp[i] = values[i];
}
for(int i = limit; i < cap; i++){
temp[i] = V();
}
delete [] values;
values = temp;
this->cap = cap;
}
template
V DynamicArray
if(index < 0 || index >= cap){
return dummy;
}
return values[index];
}
template
V& DynamicArray
if(index < 0){
return dummy;
}
if(index >= cap){
capacity(2*index);
}
return values[index];
}
#endif // DYNAMICARRAY_H_INCLUDED
**********StaticArray.h**********
#ifndef StaticArray_h
#define StaticArray_h
template
class StaticArray
{
T value[CAP];
T dummy;
public:
StaticArray();
int capacity() const;
T operator[](int) const; //getter
T& operator[](int); //setter
};
//Constructer
template
StaticArray
{
for (int i = 0; i < CAP; i++)
value[i] = T();
dummy = T();
}
//Get capacity
template
int StaticArray
{
return CAP;
}
//Getter
template
T StaticArray
{
if(index < 0 || index >= CAP)
return dummy;
return value[index];
}
//Setter
template
T& StaticArray
{
if(index < 0 || index >= CAP)
return dummy;
return value[index];
}
#endif
*******dvc.schedule.txt******
term section course instructor whenWhere
Summer 2021 5102 ADJUS-120 Morrissey NOT AVAILABLE
Summer 2021 5103 ADJUS-120 Morrissey NOT AVAILABLE
Summer 2021 5112 ADJUS-121 Ramos NOT AVAILABLE
Summer 2021 5122 ADJUS-122 Morrissey NOT AVAILABLE
Summer 2021 2230 ADJUS-150C Weaver NOT AVAILABLE
Summer 2021 5532 ADJUS-221 Weaver NOT AVAILABLE
Summer 2021 5542 ADJUS-222 Morrissey NOT AVAILABLE
Summer 2021 8336 ADS-155 Moore NOT AVAILABLE
Summer 2021 8005 ADS-168 Peterson NOT AVAILABLE
Summer 2021 3916 ANTHR-115 Johnson NOT AVAILABLE
Summer 2021 8846 ANTHR-120 Mercer NOT AVAILABLE
Summer 2021 3921 ANTHR-130 Eastland NOT AVAILABLE
Summer 2021 3923 ANTHR-130 Bazua NOT AVAILABLE
Summer 2021 5800 ANTHR-130 Eastland NOT AVAILABLE
Summer 2021 5927 ANTHR-130 Bazua NOT AVAILABLE
Summer 2021 9485 ANTHR-130 Staff NOT AVAILABLE
Summer 2021 3930 ANTHR-140 Nakama NOT AVAILABLE
Summer 2021 3931 ANTHR-140 Mercer NOT AVAILABLE
Summer 2021 8866 ANTHR-140 Mercer NOT AVAILABLE
Summer 2021 9138 ANTHR-140 Smithson NOT AVAILABLE
Summer 2021 9161 ANTHR-140 Hasten NOT AVAILABLE
Summer 2021 3940 ANTHR-141L Johnson NOT AVAILABLE
Summer 2021 8216 ANTHR-141L Mercer NOT AVAILABLE
Summer 2021 1058 ART-102 Breton NOT AVAILABLE
Summer 2021 45 ART-105 Bersamina NOT AVAILABLE
Summer 2021 9003 ART-105 Godinez NOT AVAILABLE
Summer 2021 222 ART-126 Fisher NOT AVAILABLE
Summer 2021 223 ART-127 Fisher NOT AVAILABLE
Summer 2021 5145 ART-166 Marker NOT AVAILABLE
Summer 2021 9162 ART-298 Godinez NOT AVAILABLE
Summer 2021 1933 ARTDM-105 Leeper NOT AVAILABLE
Summer 2021 4072 ARTDM-150ID King NOT AVAILABLE
Summer 2021 4102 ARTDM-150ID King NOT AVAILABLE
Summer 2021 2051 ARTDM-165 King NOT AVAILABLE
Summer 2021 2053 ARTDM-166 King NOT AVAILABLE
Summer 2021 5156 ARTDM-171 Bennett NOT AVAILABLE
Summer 2021 5007 ARTDM-214 Denning NOT AVAILABLE
Summer 2021 5021 ARTDM-214 Denning NOT AVAILABLE
Summer 2021 1057 ARTHS-193 Gand NOT AVAILABLE
Summer 2021 9004 ARTHS-195 Lederman NOT AVAILABLE
Summer 2021 5099 ARTHS-196 Gand NOT AVAILABLE
Summer 2021 5551 ARTHS-197 Gand NOT AVAILABLE
Summer 2021 1934 ARTHS-199 Koblik NOT AVAILABLE
Summer 2021 297 ASTRO-110 Chiar NOT AVAILABLE
Summer 2021 517 BIOSC-101 Wyler NOT AVAILABLE
Summer 2021 516 BIOSC-102 Hoffmann NOT AVAILABLE
Summer 2021 1149 BIOSC-102 Greene NOT AVAILABLE
Summer 2021 1150 BIOSC-102 Hoffmann NOT AVAILABLE
Summer 2021 9052 BIOSC-102 Inchauspe NOT AVAILABLE
Summer 2021 9158 BIOSC-102 Inchauspe NOT AVAILABLE
Summer 2021 1152 BIOSC-116 Fox NOT AVAILABLE
Summer 2021 9226 BIOSC-116 Galvan NOT AVAILABLE
Summer 2021 1153 BIOSC-139 Lee NOT AVAILABLE
Summer 2021 1154 BIOSC-139 Khan NOT AVAILABLE
Summer 2021 1155 BIOSC-139 Agostini NOT AVAILABLE
Summer 2021 8143 BIOSC-139 Khan NOT AVAILABLE
Summer 2021 9059 BIOSC-139 Hedayat NOT AVAILABLE
Summer 2021 9061 BIOSC-139 Yancey NOT AVAILABLE
Summer 2021 9204 BIOSC-139 Wiggins NOT AVAILABLE
Summer 2021 1157 BIOSC-146 Bloom NOT AVAILABLE
Summer 2021 1159 BIOSC-146 Staff NOT AVAILABLE
Summer 2021 9257 BIOSC-161 Reyes NOT AVAILABLE
Summer 2021 9201 BIOSC-170 Gallardo Cruz NOT AVAILABLE
Summer 2021 1191 BIOSC-171 Taugher NOT AVAILABLE
Summer 2021 1061 BUS-104 Winkler NOT AVAILABLE
Summer 2021 3350 BUS-109 Lane NOT AVAILABLE
Summer 2021 5660 BUS-109 Watkins NOT AVAILABLE
Summer 2021 5661 BUS-109 Fogli NOT AVAILABLE
Summer 2021 5662 BUS-109 Fogli NOT AVAILABLE
Summer 2021 5670 BUS-109 Pieroni NOT AVAILABLE
Summer 2021 9465 BUS-109 Zeglin NOT AVAILABLE
Summer 2021 9202 BUS-109 Zeglin NOT AVAILABLE
Summer 2021 2112 BUS-240 Lacayo NOT AVAILABLE
Summer 2021 4135 BUS-240 Lacayo NOT AVAILABLE
Summer 2021 5309 BUS-240 Shi NOT AVAILABLE
Summer 2021 5313 BUS-240 Shi NOT AVAILABLE
Summer 2021 5316 BUS-240 Shi NOT AVAILABLE
Summer 2021 5250 BUS-250 Winkler NOT AVAILABLE
Summer 2021 5323 BUS-250 Lane NOT AVAILABLE
Summer 2021 2333 BUS-294 Kasin NOT AVAILABLE
Summer 2021 5043 BUS-294 Watkins NOT AVAILABLE
Summer 2021 9460 BUS-294 Shah NOT AVAILABLE
Summer 2021 9203 BUS-294 Shah NOT AVAILABLE
Summer 2021 7646 BUS-296 Heinemann NOT AVAILABLE
Summer 2021 7647 BUS-296 Greenberg NOT AVAILABLE
Summer 2021 7648 BUS-296 Berggren NOT AVAILABLE
Summer 2021 5436 BUSAC-181 Shahbazi NOT AVAILABLE
Summer 2021 3094 BUSAC-186 Shahbazi NOT AVAILABLE
Summer 2021 5405 BUSAC-186 Puzia NOT AVAILABLE
Summer 2021 9047 BUSAC-186 Najarro NOT AVAILABLE
Summer 2021 9238 BUSAC-186 Najarro NOT AVAILABLE
Summer 2021 5673 BUSAC-187 Pieroni NOT AVAILABLE
Summer 2021 5674 BUSAC-187 Pieroni NOT AVAILABLE
Summer 2021 9049 BUSAC-187 Najarro NOT AVAILABLE
Summer 2021 9254 BUSAC-187 Najarro NOT AVAILABLE
Summer 2021 6115 BUSMG-168 Olmos NOT AVAILABLE
Summer 2021 6701 BUSMG-168 Winkler NOT AVAILABLE
Summer 2021 5758 BUSMK-158 Olmos NOT AVAILABLE
Summer 2021 5123 CARER-110 Munday NOT AVAILABLE
Summer 2021 5140 CARER-110 Hollis NOT AVAILABLE
Summer 2021 9083 CARER-110 Warren NOT AVAILABLE
Summer 2021 5093 CARER-120 Jamshidnejad NOT AVAILABLE
Summer 2021 5142 CARER-130 Lau NOT AVAILABLE
Summer 2021 5150 CARER-130 Lau NOT AVAILABLE
Summer 2021 141 CHEM-108 Yu NOT AVAILABLE
Summer 2021 2125 CHEM-108 Kulp NOT AVAILABLE
Summer 2021 4323 CHEM-108 Young NOT AVAILABLE
Summer 2021 4324 CHEM-108 Young NOT AVAILABLE
Summer 2021 4361 CHEM-108 Irias NOT AVAILABLE
Summer 2021 9063 CHEM-108 Staff NOT AVAILABLE
Summer 2021 1900 CHEM-121 Escobar NOT AVAILABLE
Summer 2021 1920 CHEM-121 Covalt NOT AVAILABLE
Summer 2021 9311 CHEM-150A Lawrence NOT AVAILABLE
Summer 2021 5154 CHIN-120 An NOT AVAILABLE
Summer 2021 5926 CHIN-299 An NOT AVAILABLE
Summer 2021 9229 CIS-100 Cabiles NOT AVAILABLE
Summer 2021 9044 CIS-101 Tejada NOT AVAILABLE
Summer 2021 9236 CIS-115 Cabiles NOT AVAILABLE
Summer 2021 9237 CIS-116 Peavler NOT AVAILABLE
Summer 2021 9239 CIS-117 Cabiles NOT AVAILABLE
Summer 2021 9241 CIS-118 Wong NOT AVAILABLE
Summer 2021 1294 CNT-101 Martucci NOT AVAILABLE
Summer 2021 4272 CNT-101 Wynn NOT AVAILABLE
Summer 2021 5182 CNT-101 Wynn NOT AVAILABLE
Summer 2021 9275 CNT-101 Huynh NOT AVAILABLE
Summer 2021 1295 CNT-102 Martucci NOT AVAILABLE
Summer 2021 4273 CNT-102 Wynn NOT AVAILABLE
Summer 2021 5187 CNT-102 Wynn NOT AVAILABLE
Summer 2021 9256 CNT-102 Huynh NOT AVAILABLE
Summer 2021 5068 CNT-146 Houshiar NOT AVAILABLE
Summer 2021 1631 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 1719 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 2390 COMM-120 Phalen NOT AVAILABLE
Summer 2021 2400 COMM-120 Phalen NOT AVAILABLE
Summer 2021 2402 COMM-120 Villa NOT AVAILABLE
Summer 2021 4156 COMM-120 Villa NOT AVAILABLE
Summer 2021 4265 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 4267 COMM-120 Perry NOT AVAILABLE
Summer 2021 4268 COMM-120 Morgan NOT AVAILABLE
Summer 2021 4269 COMM-120 Moten NOT AVAILABLE
Summer 2021 4270 COMM-120 Moten NOT AVAILABLE
Summer 2021 4271 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 4274 COMM-120 Phalen NOT AVAILABLE
Summer 2021 4275 COMM-120 Padilla NOT AVAILABLE
Summer 2021 4327 COMM-120 Phalen NOT AVAILABLE
Summer 2021 4328 COMM-120 Padilla NOT AVAILABLE
Summer 2021 5002 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 5006 COMM-120 Hawkins NOT AVAILABLE
Summer 2021 5008 COMM-120 Paiz NOT AVAILABLE
Summer 2021 5041 COMM-120 Paiz NOT AVAILABLE
Summer 2021 5066 COMM-120 Morgan NOT AVAILABLE
Summer 2021 5712 COMM-120 Johnson-Rongstad NOT AVAILABLE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started