Since it only seems to allow one attachment here is the source code for the program, the grades file will be the attachment, again thanks everyone...
// calculates the basic statistics of the test scores in the file grades.txt
// CS1410 Lab #1
// - 01/18/07 BN Basic framework developed
//
#include <iostream> // required for console i/o
#include <fstream> // required for file i/o
#include <cmath> // required for sqrt()
using namespace std;
// OK to have a 'public' constant that does NOT change
const int SIZE=99;
// function prototypes
void get_data(int score[]);
int calc_numb(int score[]);
double calc_ave(int score[]); // 70 points
double calc_stddev(int score[]); // 10 points
int calc_high(int score[]); // 10 points
int calc_low(int score[]); // 10 points
// DO NOT modify the main function of this program!!!
// -10 points if you do.
//
// modify the functions below the main function!!!
//
int main()
{
// variables
int score[SIZE];
get_data(score);
cout << "Basic Statistical analysis of scores in grades.txt \n\n";
cout << " n = " << calc_numb(score) << "\n";
cout << " average = " << calc_ave(score) << "\n";
cout << " stddev = " << calc_stddev(score) << "\n";
cout << " high score = " << calc_high(score) << "\n";
cout << " low score = " << calc_low(score) << "\n";
return 0;
}
// FUNCTION DEFINITIONS ------------------------------------
//
// GETDATA()
// reads the data from the file grades.txt and inserts into
// array score[]
// input - data in grades.txt (files ends with score=-999)
// output - data in score[]
void get_data(int score[])
{
ifstream input("grades.txt", ios::in);
int data=0;
int i=1;
for (i=0; i<SIZE; i++)
{
score[i]=0;
}
i=1;
while (data != 999)
{
input >> data;
score[i]=data;
i++;
}
score[0]=i-2;
}
// CALC_NUM()
// returns the number of test scores
// input - the score[] of test scores
// output - the number of scores in the score[]
int calc_numb(int score[])
{
return score[0];
}
// CALC_AVE()
// returns the average of test scores
// input - the score[] of test scores
// output - the average of scores in the score[]
double calc_ave(int score[])
{
return 0;
}
// CALC_STDDEV()
// returns the standard deviation of test scores
// input - the score[] of test scores
// output - the stddev of scores in the score[]
double calc_stddev(int score[])
{
return 0;
}
// CALC_HIGH()
// returns the high of test scores
// input - the score[] of test scores
// output - the high of scores in the score[]
int calc_high(int score[])
{
return 0;
}
// CALC_LOW()
// returns the low of test scores
// input - the score[] of test scores
// output - the low of scores in the score[]
int calc_low(int score[])
{
return 0;
}
Attached File(s)
-
grades.txt (133bytes)
Number of downloads: 93

New Topic/Question
Reply



MultiQuote






|