-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloadCourses.cpp
More file actions
79 lines (69 loc) · 1.33 KB
/
loadCourses.cpp
File metadata and controls
79 lines (69 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<iostream>
#include<fstream>
using namespace std;
bool loadCourses(string codelist[],string namelist[],int semesterlist[],int creditlist[])
{
string line;
int a;
ifstream file1;
file1.open("Courses.txt");
if(file1.is_open())
{
for(int i=0;!file1.eof();i++)
{
getline(file1,line,',');
if(isValidCourseCode(line))
{
codelist[i]=line;
getline(file1,line,',');
if(isValidCourseName(line))
{
namelist[i]=line;
file1>>a;
if(isValidCreditHours(a))
{
creditlist[i]=a;
file1.ignore(1,',');
file1>>a;
if(isValidSemester(a))
{
semesterlist[i]=a;
counter++;
file1.ignore(1,'\0');
}
else
{
cout<<i+1<<" SEMESTER INVALID "<<endl;
break;
}
}
else
{
cout<<i+1<<" CREDIT HOUR INVALID "<<endl;
break;
}
}
else
{
cout<<i+1<<" COURSE NAME IS INVALID "<<endl;
break;
}
}
else
{
cout<<i+1<<" COURSE CODE IS INVALID "<<endl;
break;
}
}
cout<<"COURSES LOADED SUCCESSFULLY "<<endl<<endl;
}
else
{
cout<<"ERROR OPENING FILE OR FILE DOES NOT EXIST";
}
file1.close();
}
int main()
{
return 0;
}