Errors in my gpa calculator program

Can someone please help me find the errors? I've been working on this for like forever and I just cant seem to find the problems now.

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
This program accepts
1) The full name of the student
2) Student's Degree Program
3) Student's Enrolment Year
4) Student's Enrolment Semester
5) Courses enrolled in for Current Semester
        a) Course Name
        b) Course Acronym
6) A running total of the average grade of student for each course by accepting the following:
        a) Number of quizes done
        b) Score attained in quiz
        c) Possibile Score attainable in quiz
        d) Number of exams done
        e) Score attainied in exam
        f) Possible score attainable in exam
        g) Number of assignments
        h) Score attained
        i) Possible Score Attainable   */


#include <iostream>
#include <string>
#include <fstream>

using namespace std;


double grade_average(double sum_score,int num_Quiz);//function prototype to find the average of the quizes.


int main()

{
ofstream outFile; //declares the output file

 char curr_sem[100];
 char sem[100];//semester of enrolment
 char name[256];//student mame
 char acronym[7];//array of acroynms
 char cour_Name[7];

 string degree;//Degree Program

  char courses[7];//Courses being taken

 int year;//year of enrolment
 int num_Quiz;//number of quizes taken
 int num_Cour;//number of courses taken
 double sum_score;//sum of the scores

 double average;//the average of the quizez
 double score;// the score
 double pos_Score;//possible score
 double sum_Pos_Score;//sum of possible scores

  cout <<"Please insert your name " << endl;
  cin.get(name,256);// Retrieves Student's full name

  cin.get();

  cout << "Please insert your Degree Program  " << endl;
  getline(cin,degree);
  cout<<endl;

  cout<<" Please enter year of enrolment "<<endl;
  cin>>year;

  cout<<" Please enter semester of enrolment"<<endl;
  cin>>sem;



  cout<<"Please insert the number of courses that you have taken for the semester">>num_Cour;

  if( num_Cour <1||>7)
    {
         cout<<"INCORRECT INPUT"<<endl;
    }


  for (int i=0;i<num_Cour;i++)
 {

  cout << "Please insert your Course acronym: " <<endl;
  getline(cin,acronym[i]);

  cout<<"Please insert your Course name:"<<endl;
  getline(cin,cour_Name[i]);

   cout<< "Please insert the number of quizes you have taken"<<endl;
  cin >>num_Quiz;

 for (int count=1,count<=num_Quiz,count++)

{
        cout<<" Please enter the score attained in the quiz"<<endl;
        cin>>score;
        sum_score=static_cast<int> score+sum_score;

        cout<<"Please enter the possible attainable score in the quiz"<<endl;
        cin>>pos_Score;
        sum_Pos_Score=static_cast<int>pos_Score+sum_Pos_Score;

        grade_average(sum_score,num_Quiz);

        cout<<"Sum of scores"<<sum_score<<endl;
        cout<<"Number of Quizes"<<num_Quiz<<endl;
}


 outFile.open("degree.txt");//opens the output file

  outFile <<"Name:"<<name<<" \n Degree Program:"<<degree<< "\nCourses:"<<courses<<endl;



  outFile.close();//closes the output file

return 0;
}

double grade_average(double sum_score, int num_Quiz)
       {
        int average;
        average=static_cast<int> (sum_score/num_Quiz);

        return average;
        }

                                         


Last edited on
Why did you just edit away the compiler errors??
1
2
cout<<"Please insert the number of courses that you have taken for the semester">>num_Cour;
//This is wrong------------------------------------------------------------------^ 


1
2
3
4
//This is wrong
if( num_Cour <1||>7)//wrong
//should be 
if( num_Cour <1|| num_Cour>7)


1
2
3
4
5
6
7
//The following getline functions are wrong - the second parameter to the
//getline function should be a string NOT a char
cout << "Please insert your Course acronym: " <<endl;
getline(cin,acronym[i]);
 
cout<<"Please insert your Course name:"<<endl;
getline(cin,cour_Name[i]);


1
2
//This for loop is wrong - which is strange as you had done it correctly a few lines earlier
for (int count=1,count<=num_Quiz,count++) //should be using semicolons NOT commas 



1
2
3
4
5
6
//You do not write a cast like these lines
sum_score=static_cast<int> score+sum_score;
sum_Pos_Score=static_cast<int>pos_Score+sum_Pos_Score;
//should be like this 
sum_score=static_cast<int> (score+sum_score);
sum_Pos_Score=static_cast<int> (pos_Score+sum_Pos_Score);


If you count the number of opening braces { and the number of closing
braces } you will see that they don't match up.

Topic archived. No new replies allowed.