Grading in C++ using files as an input [on hold]











up vote
-5
down vote

favorite












In an English class, a student is given 4 term tests (each marked out of 50) and one final exam (marked out of 100). Each term test is weighted at 20% of the overall mark for the course and the final exam is also weighted at 20%. Write a program Grades.cpp to read marks for the 4 term tests followed by the mark for the final exam from a file "input.txt". The program then prints the final overall mark as well as the grade for each student. The file contains data for exactly 5 candidates. The structure of the data is given later. The grading scheme follows.



A (75-100), B (60-74), C (50-59), F (under 50).
sample of the first data line is:



1582 20 10 15 30 60



# include <iostream>
# include <string>
# include <fstream>
using namespace std;
struct studentType
{
string studentid;
double coursework[4];
double finals;
char grade;
};
int main()
{
ifstream inFile;
inFile.open("grades.txt");
string id;
double c[4];
double f;
while (!inFile.fail())
{
inFile >> id;
for ( int j=0; j<5; j++)
inFile >> c[j];
inFile >> f;
}
inFile.close();
}
{
ifstream inFile;
inFile.open("grades.txt");
for(int i=0; i<n; i++)
{
inFile >> s[i].studentid;
for (int j=0; j<5; j++)
inFile >> s[i].coursework[j];
}
inFile >> s[i].final;
inFile.close();
}

for (int i=0; i<n; i++)
{
cwtotal = s[i].coursework[0]+s[i].coursework[1]+s[i].coursework[2]+s[i].coursework[4];
s[i].cwweight = ((cwtotal/200))* 80;
}
}
void finalweight ()
{
for (int i=0; i<n; i++)
{
(s[i].final/100)*20);
}
}
void finalaverage ()
{ for (int i=0; i<n; i++)
{ (s[i].final/100)*20) + (s[i].cwweight = ((cwtotal/200))* 80)
}
}
void displayData ()
{
cout << "Student ID Course% Final% Average% Grade ";
cout << "___________________________________________________________nn";
for (int i=0; i<n; i++)
{
cout << s[i].studentid << " ";
cout << s[i].cwweight << "t";
cout << s[i].final << "t";
cout << s[i].grade;
cout << endl << endl;
}
cout << endl;
}
void grade()
{
char grade;
for (int i=0; i<n; i++)
{
if(s[i].average<=100 && s[i].average>=75)
grade = 'A';
else if(s[i].average<75 && s[i].average>=60)
grade = 'B';
else if(s[i].average<59 && s[i].average>=50)
grade = 'C';
else if(s[i].average<50)
grade = 'F';
s[i].grade = grade;
}
}


Im not getting it to compile not sure if im taking the code in the right way. Im new to code on the whole. Any help will be really good. If there is anyother way to do this question it would be nice to explain it and I will try again. Thank you from early










share|improve this question







New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Calak
    2 days ago















up vote
-5
down vote

favorite












In an English class, a student is given 4 term tests (each marked out of 50) and one final exam (marked out of 100). Each term test is weighted at 20% of the overall mark for the course and the final exam is also weighted at 20%. Write a program Grades.cpp to read marks for the 4 term tests followed by the mark for the final exam from a file "input.txt". The program then prints the final overall mark as well as the grade for each student. The file contains data for exactly 5 candidates. The structure of the data is given later. The grading scheme follows.



A (75-100), B (60-74), C (50-59), F (under 50).
sample of the first data line is:



1582 20 10 15 30 60



# include <iostream>
# include <string>
# include <fstream>
using namespace std;
struct studentType
{
string studentid;
double coursework[4];
double finals;
char grade;
};
int main()
{
ifstream inFile;
inFile.open("grades.txt");
string id;
double c[4];
double f;
while (!inFile.fail())
{
inFile >> id;
for ( int j=0; j<5; j++)
inFile >> c[j];
inFile >> f;
}
inFile.close();
}
{
ifstream inFile;
inFile.open("grades.txt");
for(int i=0; i<n; i++)
{
inFile >> s[i].studentid;
for (int j=0; j<5; j++)
inFile >> s[i].coursework[j];
}
inFile >> s[i].final;
inFile.close();
}

for (int i=0; i<n; i++)
{
cwtotal = s[i].coursework[0]+s[i].coursework[1]+s[i].coursework[2]+s[i].coursework[4];
s[i].cwweight = ((cwtotal/200))* 80;
}
}
void finalweight ()
{
for (int i=0; i<n; i++)
{
(s[i].final/100)*20);
}
}
void finalaverage ()
{ for (int i=0; i<n; i++)
{ (s[i].final/100)*20) + (s[i].cwweight = ((cwtotal/200))* 80)
}
}
void displayData ()
{
cout << "Student ID Course% Final% Average% Grade ";
cout << "___________________________________________________________nn";
for (int i=0; i<n; i++)
{
cout << s[i].studentid << " ";
cout << s[i].cwweight << "t";
cout << s[i].final << "t";
cout << s[i].grade;
cout << endl << endl;
}
cout << endl;
}
void grade()
{
char grade;
for (int i=0; i<n; i++)
{
if(s[i].average<=100 && s[i].average>=75)
grade = 'A';
else if(s[i].average<75 && s[i].average>=60)
grade = 'B';
else if(s[i].average<59 && s[i].average>=50)
grade = 'C';
else if(s[i].average<50)
grade = 'F';
s[i].grade = grade;
}
}


Im not getting it to compile not sure if im taking the code in the right way. Im new to code on the whole. Any help will be really good. If there is anyother way to do this question it would be nice to explain it and I will try again. Thank you from early










share|improve this question







New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Calak
    2 days ago













up vote
-5
down vote

favorite









up vote
-5
down vote

favorite











In an English class, a student is given 4 term tests (each marked out of 50) and one final exam (marked out of 100). Each term test is weighted at 20% of the overall mark for the course and the final exam is also weighted at 20%. Write a program Grades.cpp to read marks for the 4 term tests followed by the mark for the final exam from a file "input.txt". The program then prints the final overall mark as well as the grade for each student. The file contains data for exactly 5 candidates. The structure of the data is given later. The grading scheme follows.



A (75-100), B (60-74), C (50-59), F (under 50).
sample of the first data line is:



1582 20 10 15 30 60



# include <iostream>
# include <string>
# include <fstream>
using namespace std;
struct studentType
{
string studentid;
double coursework[4];
double finals;
char grade;
};
int main()
{
ifstream inFile;
inFile.open("grades.txt");
string id;
double c[4];
double f;
while (!inFile.fail())
{
inFile >> id;
for ( int j=0; j<5; j++)
inFile >> c[j];
inFile >> f;
}
inFile.close();
}
{
ifstream inFile;
inFile.open("grades.txt");
for(int i=0; i<n; i++)
{
inFile >> s[i].studentid;
for (int j=0; j<5; j++)
inFile >> s[i].coursework[j];
}
inFile >> s[i].final;
inFile.close();
}

for (int i=0; i<n; i++)
{
cwtotal = s[i].coursework[0]+s[i].coursework[1]+s[i].coursework[2]+s[i].coursework[4];
s[i].cwweight = ((cwtotal/200))* 80;
}
}
void finalweight ()
{
for (int i=0; i<n; i++)
{
(s[i].final/100)*20);
}
}
void finalaverage ()
{ for (int i=0; i<n; i++)
{ (s[i].final/100)*20) + (s[i].cwweight = ((cwtotal/200))* 80)
}
}
void displayData ()
{
cout << "Student ID Course% Final% Average% Grade ";
cout << "___________________________________________________________nn";
for (int i=0; i<n; i++)
{
cout << s[i].studentid << " ";
cout << s[i].cwweight << "t";
cout << s[i].final << "t";
cout << s[i].grade;
cout << endl << endl;
}
cout << endl;
}
void grade()
{
char grade;
for (int i=0; i<n; i++)
{
if(s[i].average<=100 && s[i].average>=75)
grade = 'A';
else if(s[i].average<75 && s[i].average>=60)
grade = 'B';
else if(s[i].average<59 && s[i].average>=50)
grade = 'C';
else if(s[i].average<50)
grade = 'F';
s[i].grade = grade;
}
}


Im not getting it to compile not sure if im taking the code in the right way. Im new to code on the whole. Any help will be really good. If there is anyother way to do this question it would be nice to explain it and I will try again. Thank you from early










share|improve this question







New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In an English class, a student is given 4 term tests (each marked out of 50) and one final exam (marked out of 100). Each term test is weighted at 20% of the overall mark for the course and the final exam is also weighted at 20%. Write a program Grades.cpp to read marks for the 4 term tests followed by the mark for the final exam from a file "input.txt". The program then prints the final overall mark as well as the grade for each student. The file contains data for exactly 5 candidates. The structure of the data is given later. The grading scheme follows.



A (75-100), B (60-74), C (50-59), F (under 50).
sample of the first data line is:



1582 20 10 15 30 60



# include <iostream>
# include <string>
# include <fstream>
using namespace std;
struct studentType
{
string studentid;
double coursework[4];
double finals;
char grade;
};
int main()
{
ifstream inFile;
inFile.open("grades.txt");
string id;
double c[4];
double f;
while (!inFile.fail())
{
inFile >> id;
for ( int j=0; j<5; j++)
inFile >> c[j];
inFile >> f;
}
inFile.close();
}
{
ifstream inFile;
inFile.open("grades.txt");
for(int i=0; i<n; i++)
{
inFile >> s[i].studentid;
for (int j=0; j<5; j++)
inFile >> s[i].coursework[j];
}
inFile >> s[i].final;
inFile.close();
}

for (int i=0; i<n; i++)
{
cwtotal = s[i].coursework[0]+s[i].coursework[1]+s[i].coursework[2]+s[i].coursework[4];
s[i].cwweight = ((cwtotal/200))* 80;
}
}
void finalweight ()
{
for (int i=0; i<n; i++)
{
(s[i].final/100)*20);
}
}
void finalaverage ()
{ for (int i=0; i<n; i++)
{ (s[i].final/100)*20) + (s[i].cwweight = ((cwtotal/200))* 80)
}
}
void displayData ()
{
cout << "Student ID Course% Final% Average% Grade ";
cout << "___________________________________________________________nn";
for (int i=0; i<n; i++)
{
cout << s[i].studentid << " ";
cout << s[i].cwweight << "t";
cout << s[i].final << "t";
cout << s[i].grade;
cout << endl << endl;
}
cout << endl;
}
void grade()
{
char grade;
for (int i=0; i<n; i++)
{
if(s[i].average<=100 && s[i].average>=75)
grade = 'A';
else if(s[i].average<75 && s[i].average>=60)
grade = 'B';
else if(s[i].average<59 && s[i].average>=50)
grade = 'C';
else if(s[i].average<50)
grade = 'F';
s[i].grade = grade;
}
}


Im not getting it to compile not sure if im taking the code in the right way. Im new to code on the whole. Any help will be really good. If there is anyother way to do this question it would be nice to explain it and I will try again. Thank you from early







c++






share|improve this question







New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









christopher garjew

11




11




New contributor




christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






christopher garjew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, tinstaafl, 200_success, hoffmale, Malachi

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Calak
    2 days ago














  • 1




    Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Calak
    2 days ago








1




1




Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Calak
2 days ago




Welcome on Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Calak
2 days ago















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Ellipse (mathématiques)

Quarter-circle Tiles

Mont Emei