Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void promptUser();
- void readData();
- void calculateStdDeviations();
- void calculateSumsAndMeans();
- void runProgram();
- void outputData();
- const int rows=10;
- const int cols=2;
- int scores [rows][cols];
- int sumVerbal;
- int sumMath;
- int meanVerbal;
- int meanMath;
- double valMath;
- double valVerbal;
- ifstream outFile;
- void runProgram()
- {
- promptUser();
- readData();
- calculateSumsAndMeans();
- calculateStdDeviations();
- }
- int main()
- {
- runProgram();
- }
- void promptUser()
- {
- cout<<"In this program the user will input the SAT scores of 10 /n"
- <<"students and find the mean and standard deviation of the scores."<< endl <<endl;
- }
- void readData()
- {
- int mathInput;
- int verbalInput;
- for(int i =0;i<rows; i++ )
- {
- cout<<"Please enter the " << i + 1<< " math score and the " << i + 1<< " verbal score";
- cin>> mathInput >>verbalInput;
- scores[i][0]= mathInput;
- scores[i][1]= verbalInput;
- }
- void calculateSumsAndMeans()
- {
- sumVerbal=0;
- sumMath=0;
- for(int i =0;i<rows; i++ )
- {
- sumMath = sumMath + scores[i][0];
- sumVerbal = sumVerbal + scores[i][1];
- }
- meanMath = sumMath/rows;
- meanVerbal = sumVerbal/rows;
- }
- void calculateStdDeviations()
- {
- for(int i =0;i<rows; i++ )
- {
- valMath = scores[i][0]-meanMath;
- valMath = valMath*valMath;
- valVerbal = scores[i][1] - meanVerbal;
- valVerbal = valVerbal*valVerbal;
- }
- }
- void sendResults()
- {
- cout<<"Math Verbal" << endl;
- for(int i = 0; i<rows: i++)
- {
- cout << scores[i][0] << " " << scores[i][1] << endl;
- }
- cout << meanMath << " " << meanVerbal<< endl;
- cout << mathDev << " "<< mathVerbal<< endl;
- outfile.open("output.txt");
- outfile << "Math Verbal" << endl;
- for(int i = 0; i<rows: i++)
- {
- outfile << scores[i][0] << " " << scores[i][1] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement