Created
October 7, 2014 06:31
-
-
Save ConatserCA/4803c10acddad5836f73 to your computer and use it in GitHub Desktop.
Read exam scores from ExamScores.txt (Copy and paste these numbers "67 64 83 81 72 75 85 81 56 88 71 80 90 58 78 74 84 64 72 69 78 87 84 72 83 68 62 88 70 75" into a txt document) 1. Calculate average score and display. 2. Find Min and Max scores and display. 3. Display scores in rows of three scores.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Connor Conatser | |
9/30/14 | |
Exam Scores | |
*/ | |
#include <iostream> | |
#include <fstream> | |
#include <iomanip> | |
using namespace std; | |
int main() | |
{ | |
//initializing integers | |
int score(0), scoreNum(0), min(10000), max(-10000), sum(0); | |
double avg(0.0); | |
//binding string examScores to the txt doc | |
string examScores("ExamScores.txt"); | |
ifstream inFile; | |
inFile.open(examScores.c_str()); | |
while ( ! inFile.eof() ) | |
{ | |
++scoreNum; | |
sum += score; | |
//cout << score << endl; | |
inFile >> score; | |
if (score > max) | |
{ | |
max = score; | |
} | |
if (score < min) | |
{ | |
min = score; | |
} | |
} | |
//inFile.close(); | |
avg = sum / (double)scoreNum; | |
cout << setprecision(0) << fixed; | |
cout << "Total Class Average: " <<setw(4)<< avg << endl; | |
cout << "The maximum score is: " << setw(3)<< max << endl; | |
cout << "The minimum score is: " << setw(3)<< min << endl; | |
cout << endl << endl; | |
cout << "Couldn't figure out how to do the columns successfuly, also couldn't figure out how to put them after the min & max" << endl << endl; | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment