Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. void promptUser();
  8. void readData();
  9. void calculateStdDeviations();
  10. void calculateSumsAndMeans();
  11. void runProgram();
  12. void outputData();
  13.  
  14. const int rows=10;
  15. const int cols=2;
  16.  
  17.  
  18. int scores [rows][cols];
  19.  
  20.  
  21. int sumVerbal;
  22. int sumMath;
  23. int meanVerbal;
  24. int meanMath;
  25. double valMath;
  26. double valVerbal;
  27.  
  28.  
  29. ifstream outFile;
  30.  
  31. void runProgram()
  32. {
  33. promptUser();
  34. readData();
  35. calculateSumsAndMeans();
  36. calculateStdDeviations();
  37.  
  38. }
  39.  
  40. int main()
  41. {
  42.  
  43.  
  44. runProgram();
  45.  
  46. }
  47.  
  48.  
  49. void promptUser()
  50. {
  51.  
  52. cout<<"In this program the user will input the SAT scores of 10 /n"
  53. <<"students and find the mean and standard deviation of the scores."<< endl <<endl;
  54.  
  55.  
  56. }
  57.  
  58. void readData()
  59. {
  60.  
  61.  
  62. int mathInput;
  63. int verbalInput;
  64. for(int i =0;i<rows; i++ )
  65. {
  66. cout<<"Please enter the " << i + 1<< " math score and the " << i + 1<< " verbal score";
  67. cin>> mathInput >>verbalInput;
  68.  
  69. scores[i][0]= mathInput;
  70. scores[i][1]= verbalInput;
  71.  
  72.  
  73.  
  74. }
  75.  
  76. void calculateSumsAndMeans()
  77. {
  78.  
  79. sumVerbal=0;
  80. sumMath=0;
  81.  
  82. for(int i =0;i<rows; i++ )
  83. {
  84.  
  85. sumMath = sumMath + scores[i][0];
  86. sumVerbal = sumVerbal + scores[i][1];
  87.  
  88.  
  89.  
  90. }
  91. meanMath = sumMath/rows;
  92. meanVerbal = sumVerbal/rows;
  93.  
  94.  
  95.  
  96. }
  97. void calculateStdDeviations()
  98. {
  99. for(int i =0;i<rows; i++ )
  100. {
  101. valMath = scores[i][0]-meanMath;
  102. valMath = valMath*valMath;
  103. valVerbal = scores[i][1] - meanVerbal;
  104. valVerbal = valVerbal*valVerbal;
  105.  
  106.  
  107. }
  108.  
  109. }
  110.  
  111. void sendResults()
  112. {
  113. cout<<"Math Verbal" << endl;
  114. for(int i = 0; i<rows: i++)
  115. {
  116. cout << scores[i][0] << " " << scores[i][1] << endl;
  117. }
  118. cout << meanMath << " " << meanVerbal<< endl;
  119. cout << mathDev << " "<< mathVerbal<< endl;
  120.  
  121. outfile.open("output.txt");
  122. outfile << "Math Verbal" << endl;
  123. for(int i = 0; i<rows: i++)
  124. {
  125. outfile << scores[i][0] << " " << scores[i][1] << endl;
  126. }
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement