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;
}
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.