Basis for the code:
Using a .txt file with names, grades (assignments & tests), and attendance, determine average (then pass/fail), and determine pass/fail based on attendance.
Anything under a 60 = fail.
Attendance under 30=fail.
Here's what I have:
Code:
//This program averages grades and determines pass/fail.
//It also determines pass/fail through attendance
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile;
int first, last, a1, a2, a3, a4, t1, t2, attendance;
double test, assignment, average;
inFile.open("d:\\grades.txt"); //Using d: because I have no a: drive
cout <<"Reading Data from file."<<endl;
//Average first set of grades
inFile >> first;
inFile >> last;
inFile >> a1;
inFile >> a2;
inFile >> a3;
inFile >> a4;
inFile >> t1;
inFile >> t2;
inFile >> attendance;
assignment = (a1+a2+a3+a4)/4;
test = (t1+t2)/2;
average = (assignment + test)/2;
cout <<first<<last<<"average is: "<<average<<endl;
if (average < 60)
cout<<"\nStudent has failed to meet grade requirements.";
if (average >= 60)
cout<<"\nStudent has passed the grade requirements.";
if (attendance < 30)
cout<<"\nStudent has failed due to poor attendance.";
if (attendance >=30)
cout<<"\nStudent has passed the attendance requirement.";
//Close the file
inFile.close();
cout<<"\nDone.\n";
return 0;
}