Probably not the perfect style, i had not a lot of time to care of this.
Check if the average result and precision is correct.
// st.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
int main()
{
ifstream scoredata;
scoredata.open("ScoreData.txt");
if(scoredata.fail())
{
cout << "File not found. Program terminated." << endl;
return 1;
} //end if
//Prints the table that indicates names, quiz number, lowest score, and average.
cout << "Name";
for (int i = 1; i <= 10; i++)
cout << setw(5) << i;
cout << setw(5) << "Low";
cout << setw(5) << "Avg";
cout << endl;
//////////////////////////////////////////////////////////////////
char student_first_name, student_last_name;
int quiz_score;
double a;
double b;
double average;
int lowest_score;
///////////////////////////////////////////////////////////////////
while(!scoredata.eof())
{
quiz_score = 0;
a = 0;
b = 0;
average = 0.0;
lowest_score =20;
scoredata >> student_first_name >> student_last_name;
cout << student_first_name << "." << student_last_name << setw(6);
//Students scores, puts them in the table
for(i = 1; i <= 11; i++)
{
if (quiz_score != -1) scoredata >> quiz_score;
if (quiz_score != -1)
{
cout << quiz_score << setw(5);
a++;
b += quiz_score;
//Gets the Lowest score out of the set
if(quiz_score < lowest_score)
{
lowest_score = quiz_score;
}
} //end if quiz != -1
// If the students didn't do the test/quiz the space is left blank.
else
if (i < 11 ) cout << setw(5) << " ";
} //end for i 1 - 10
//Lowest Score
if(a > 1)
cout << setw(5) << lowest_score;
else
cout << setw(5) << "N/A";
//Average Score and it also drops the lowest score.
static_cast<double>(a);
static_cast<double>(b);
if(a > 1)
{
a -= 1;
average = (b - lowest_score) / a;
cout << fixed << setprecision(1) << showpoint;
cout << setw(5) << average << endl;
}
else if(a == 1)
cout << setw(5) << b;
cout << endl;
////////////////////////////////////////////////////////////////
} // end while not end of file
scoredata.close();
cout << endl;
return 0;
} // end main