943,682 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1651
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 19th, 2009
0

Gradebook Project help c++ with two dimensional arrays

Expand Post »
Good Morning,
I'm having some problems with my code. This program is to have at least 5 functions .
1.)Ingrades: a two dimensional array that stores student ID, grades and times absent.
2.)Score. Calculates scores for all course work (two partial tests 15% each , two quizzes 10 %each, 1 project 20%1 final 30%.
3.standev - calculates the standard deviation of each course work
4.Modif - lets user modify any score or absent total
5.ViewGradesl: outputs all the grades for each student ID entered

My problem so far, my code runs, but I'm having major problems with the following functions:

1.)Ingrade: my problem here is that I'm not really sure in which index I'm storing the Absence Count.
2.) Score : I made it really simple assuming all scores where the same. But I'm having problems trying to give a 15% value to tests and 10% ten to quizzes and so on.. so in the end I can compute the final grade correctly. And also I have problems when running the subtraction of -1% if student is absent it is deducted a 1% of the final grade. and if the student is absent more than than ten times it is an F. I can put all 100 and 1 absent and the program sometimes gives out an F.

3.)standev: This works ok (I think )

4.) Modif: welll , where to start with this one?. It is supposed to modify the original array with new grades for each student ID and then recompute using function score. but any sort of value I enter I don't know where I'm sending it. I thought I was sending it to the original array but apparently I'm not

5.) ViewGrades works ok, displaying each student id and all grades , but I wish to modify it to actually display some sort of table.


I would gladly appreciate any ideas or help I'm exhausted with this project

C++ Syntax (Toggle Plain Text)
  1.  
  2.  
  3.  
  4. #include<iostream> //Librerias
  5. #include<cmath> //Librerias
  6. using namespace std;
  7.  
  8. /* Function prototypes */
  9.  
  10. void Ingrades (double[][10], int); // Function that lets user input student ID, two partial exams one final, two quizzes and one project and studentCount of twenty classes
  11. void Score (double[][10], int);//Score and mean calculations
  12. void Standev (double[][10], int); //Function that calculates standard deviation
  13. void Modif (double [][10], int); //Function that lets user change any student grades for any test and studentCount
  14. void ViewGrades (double[][10], int); //Function that displays the Score of each test for each student and outputs the final grade.
  15. int main ()
  16. {
  17. const int studentCount=15, studentRecords=10;//We initialize arrays to dimensions studentCount is twenty max number of classes and studentRecords fifteen max number of students.
  18. int option, i, studentID;
  19.  
  20. /* MultiDemensional Array : first dimension is fifteen that represents the student count
  21. Second dimension is ten that represents the student records to be modified
  22. zero row represents students ID
  23. rows one to seven represents student grades composed of : two partial tests, two quizzes, one project and one final
  24. row eight represent ABSENCES
  25. row nine represents final grade
  26. */
  27.  
  28. double gradeBook[studentCount][studentRecords];
  29.  
  30.  
  31.  
  32. cout<<" \t \t Student GradeBook "<<endl;
  33.  
  34. cout<<"Enter the amount of the students (1 to 15): ";
  35. cin>>studentID; // asks for total number of students
  36. while(studentID<1 ||studentID>15)//student count is 15
  37. {
  38. cout<<"The student quantity should be from 1 to 15. \nPlease Re-Enter: ";
  39. cin>>studentID;
  40. }
  41. for (i=0; i<studentID; i++)//Array initialized to 0
  42. {
  43. gradeBook[i][0]=0;
  44. gradeBook[i][10]=-1;
  45. }
  46. do // do loop for menu
  47. {
  48. option=0;
  49. /* Options Menu*/
  50. cout<<"1. Enter the student grades (2 partial exams, 2 quizzes, 1 proyect 1 final ) and studentRecords (20 total attendance)"<<endl;
  51. cout<<"2. Compute each student's mean score and final grade"<<endl;
  52. cout<<"3. Compute the variance and the standard deviation for each exam and final score";
  53. cout<<"4. Modify Grades"<<endl;
  54. cout<<"5. List the Grades"<<endl;
  55. cout<<"6. Exit"<<endl;
  56. cout<<"Please choose an option: ";
  57. cin>>option;
  58. cout<<endl<<endl;
  59. while(option<1||option>6)// validation loop
  60. {
  61. cout<<"ERROR INVALID SELECTION"<<endl;
  62. cout<<"Please, re-enter one of the earlier options: ";
  63. cin>>option;
  64. }
  65. switch (option)// Selection menu to populate the arrays
  66. {
  67. case 1:
  68. if(gradeBook[0][0]!=0)// validation statement
  69. {
  70. cout<<"This process can't be done again."<<endl;
  71. cout<<"Select options 2-6."<<endl<<endl;
  72. }
  73. else
  74. Ingrades(gradeBook, studentID);//call for Ingrades function with gradebook and studentID
  75. break;
  76. case 2:
  77. Score(gradeBook, studentID);//calls for function Score that calculates scores for gradebook and student id dimensions
  78. break;
  79. case 3:
  80. Standev(gradeBook, studentID);// calls for function Standdev for a all tests
  81. break;
  82. case 4:
  83. Modif(gradeBook, studentID);//calls for function Modif that lets user modify any student record including test and Attendance
  84. break;
  85. case 5:
  86. ViewGrades(gradeBook, studentID);//View Grades for entire class or students entered
  87. break;
  88. case 6:
  89. cout<<"GOOD BYE "<<endl<<endl;
  90. break;
  91. }
  92. // All functions called and they send parameters to each function definition.
  93. }while(option>=1&&option<=5);
  94. return 0;
  95. }
  96. //end main
  97.  
  98. /* Function DEFINITIONS */
  99.  
  100.  
  101. void Ingrades (double gradeBook[][10],int studentCount)//
  102. {
  103. // i represents students count and j represents student data: grades, ID and absent count
  104. int i, j;
  105. for(i=0; i<studentCount; i++)//studentCout initialized to 0
  106. {
  107. for(j=0; j<1; j++)// For repetition cycle that asks for students ID
  108. {
  109. cout<<"Enter the student's ID number: ";
  110. cin>>gradeBook[i][j];
  111. while(gradeBook[i][j]<=0)//Student id cannot be <= 0
  112. {
  113. cout<<"Invalid ID Number. Re-enter again....: ";
  114. cin>>gradeBook[i][j];
  115. }
  116. }
  117. cout<<"Enter in the following order: \n test1 = 1, test2= 2, quiz1= 3, quiz2= 4, project1= 5 FINAL =6"<<endl;
  118.  
  119. for(j=1; j<7; j++)//
  120. {
  121. cout<<"Enter the grades "<<j<<": ";
  122. cin>>gradeBook[i][j];
  123. while(gradeBook[i][j]>100||gradeBook[i][j]<0)// gradeBook validated that grades cannot be lower than zero and greater than a hundred
  124. {
  125. cout<<"INVALID GRADES"<<endl;
  126. cout<<"Please Re-Enter: ";
  127. cin>>gradeBook[i][j];
  128. }
  129. }
  130. for(j=8; j<9; j++)//Counts for Absences
  131. {
  132. cout<<"Enter the student's number of absences (Total of clases: 20): ";
  133. cin>>gradeBook[i][j];
  134. while(gradeBook[i][j]<0||gradeBook[i][j]>20)// while validation Class total is twenty , Absences cannot be more than the total of classes
  135. {
  136. cout<<"**The number of absences exceed the number of classes**"<<endl;
  137. cout<<"Re-enter: ";
  138. cin>>gradeBook[i][j];
  139. }
  140. cout<<endl<<endl;
  141. }
  142. }
  143. }
  144. void Score (double gradeBook[][10],int studentCount)//Function that calculates students grade
  145. {
  146. int i, j;
  147. for (i=0; i<studentCount; i++) // To call for this function you have to select option 1 in main that populates student Records
  148. if (gradeBook[i][0]==0)
  149. {
  150. cout<<"***No students were registered***.";
  151. cout<<"Select Option 1."<<endl;
  152. break;
  153. }
  154. else // IF there's a valid ID entered then function is executed
  155. {
  156.  
  157. for (i=0; i<studentCount; i++)
  158. {
  159. if(gradeBook[i][8]>=10) //row eight is where ABSENCES are stored
  160. gradeBook[i][10]=0;//If there are more than ten ABSENCES then GRADE is F
  161. else
  162. {
  163. for(i=0; i<studentCount; i++)
  164. {
  165. for (j=0; j<gradeBook[i][8]; j++)
  166. gradeBook[i][10]-=1.0;//Rests 1.0% out of the final grade for each ABSENCE
  167. if(gradeBook[i][10]<0)
  168. gradeBook[i][10]=0;//IF Final grade is negative then score is F.
  169. }
  170. }
  171. }
  172. }
  173. cout<<"*************************************"<<endl;
  174. cout<<"* All the calculations have been done *"<<endl;//
  175. cout<<"*************************************"<<endl<<endl<<endl<<endl;
  176. }
  177. void Standev (double gradeBook[][10], int studentCount)//Function that calculates Standard Deviation
  178. {
  179. int i, j, a, w;
  180. double sum, average, rum, stdVariance, std_deviation;
  181. for(a=0; a<studentCount; a++)
  182. { // Validation for initial values of the array, GRADES must be entered for this function to work
  183. if (gradeBook[0][0]==0)
  184. {
  185. cout<<"No Grades were registered."<<endl;
  186. cout<<"Select Option 1."<<endl;
  187. break;
  188. }
  189. else if(gradeBook[0][10]==-1)
  190. {
  191. cout<<"No calculations have been made nor grades were registrered."<<endl;
  192. cout<<"Select Option 2."<<endl<<endl<<endl;
  193. break;
  194. }
  195. else
  196. {
  197. do// Repeats Standard Deviation MENU
  198. {
  199. cout<<"Press 1 to see the variance and standard deviation of the first exam."<<endl;
  200. cout<<"Press 2 to see the variance and standard deviation of the second exam."<<endl;
  201. cout<<"Press 3 to see the variance and standard deviation of the first quiz"<<endl;
  202. cout<<"Press 4 to see the variance and standard deviation of the second quiz"<<endl;
  203. cout<<"Press 5 to see the variance and standard deviation of the project 1"<<endl;
  204. cout<<"Press 6 to see the variance and standard deviation of the final exam."<<endl;
  205. cout<<"Press 7 to see the variance and standard deviation of the final score."<<endl;
  206. cout<<"Press 8 to exit."<<endl;
  207. sum=0;
  208. rum=0;
  209. average;
  210. stdVariance=0;
  211. std_deviation=0;
  212. w=0; // Second menu Selection
  213. cin>>w;
  214. while(w<1||w>8)//Validates MENU
  215. {
  216. cout<<"***Error***===Please Re-Enter.";
  217. cin>>w;
  218. }
  219. switch (w)
  220. { // Each CASE Computes the standard deviation of all grades for each EXAM
  221. case 1:
  222. for(i=0; i<studentCount; i++)
  223. for(j=1; j<2; j++)
  224. sum+=gradeBook[i][j];//Sums all of the GRADES of Examn ONE.
  225. average=sum/studentCount;//Divide the sum of the GRADES entered by the total of students entered (Average)
  226. for(i=0; i<studentCount; i++)
  227. for(j=1; j<2; j++)
  228. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);//Stores the sum in a variable
  229. stdVariance=rum/(studentCount-1);//divides the calculation by the total number of grades minus one to get curve
  230. std_deviation=sqrt(stdVariance); // sqrt of variation, using sqrt from cmath library gives out the Std deviation
  231. cout<<"Variance for the first test is: "<<stdVariance<<endl;
  232. cout<<"Standard deviation for the first test is is: "<<std_deviation<<endl<<endl;
  233. break;
  234. case 2: //Calculates standard deviation for the second test
  235. for(i=0; i<studentCount; i++)
  236. for(j=2; j<3; j++)
  237. sum+=gradeBook[i][j];
  238. average=sum/studentCount;
  239. for(i=0; i<studentCount; i++)
  240. for(j=2; j<3; j++)
  241. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
  242. stdVariance=rum/(studentCount-1);
  243. std_deviation=sqrt(stdVariance);
  244. cout<<"Variance for the second test is: "<<stdVariance<<endl;
  245. cout<<"Standard deviation for the second test is is: "<<std_deviation<<endl<<endl;
  246. break;
  247. case 3: //Calculates standard deviation for quiz one
  248. for(i=0; i<studentCount; i++)
  249. for(j=3; j<4; j++)
  250. sum+=gradeBook[i][j];
  251. average=sum/studentCount;
  252. for(i=0; i<studentCount; i++)
  253. for(j=3; j<4; j++)
  254. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
  255. stdVariance=rum/(studentCount-1);
  256. std_deviation=sqrt(stdVariance);
  257. cout<<"Variance for the first quiz is: "<<stdVariance<<endl;
  258. cout<<"Standard deviation for the first quiz is: "<<std_deviation<<endl<<endl;
  259. break;
  260. case 4://Calculates standard deviation for quiz two
  261. for(i=0; i<studentCount; i++)
  262. for(j=4; j<5; j++)
  263. sum+=gradeBook[i][j];
  264. average=sum/studentCount;
  265. for(i=0; i<studentCount; i++)
  266. for(j=4; j<5; j++)
  267. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
  268. stdVariance=rum/(studentCount-1);
  269. std_deviation=sqrt(stdVariance);
  270. cout<<"Variance for the second quiz is: "<<stdVariance<<endl;
  271. cout<<"Standard deviation for the second quiz is: "<<std_deviation<<endl<<endl;
  272. break;
  273. case 5://Calculates standard deviation for project
  274. for(i=0; i<studentCount; i++)
  275. for(j=5; j<6; j++)
  276. sum+=gradeBook[i][j];
  277. average=sum/studentCount;
  278. for(i=0; i<studentCount; i++)
  279. for(j=5; j<6; j++)
  280. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
  281. stdVariance=rum/(studentCount-1);
  282. std_deviation=sqrt(stdVariance);
  283. cout<<"Variance for the project is: "<<stdVariance<<endl;
  284. cout<<"Standard deviation for the project is : "<<std_deviation<<endl<<endl;
  285. break;
  286.  
  287. case 6: //calculates standard deviation for FINAL TEST
  288. for (i=0; i<studentCount; i++)
  289. for (j=7; j<8; j++)
  290. sum+=gradeBook[i][j];
  291. average=sum/studentCount;
  292. for(i=0; i<studentCount; i++)
  293. for(j=7; j<8; i++)
  294. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
  295. stdVariance=rum/(studentCount - 1);
  296. std_deviation=sqrt (stdVariance);
  297. cout<<"Variance for the final exam is: "<<stdVariance<<endl;
  298. cout<<"Standard deviation for the final exam is: "<<std_deviation<<endl<<endl;
  299. break;
  300. case 7: // calculates the standard deviation of the FINAL GRADE
  301. for(i=0; i<studentCount; i++)
  302. for(j=8; j<9; j++)
  303. sum+=gradeBook[i][j];//Sums all of the GRADES of Final Grade.
  304. average=sum/studentCount;//Divide the sum of the GRADES entered by the total of students entered (Average)
  305. for(i=0; i<studentCount; i++)
  306. for(j=8; j<9; j++)
  307. rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);//Stores the sum in a variable
  308. stdVariance=rum/(studentCount-1);//divides the calculation by the total number of grades minus one to get curve
  309. std_deviation=sqrt(stdVariance); // sqrt of variation, using sqrt from cmath library gives out the Std deviation
  310. cout<<"Variance for the FINAL GRADE is: "<<stdVariance<<endl;
  311. cout<<"Standard deviation for the FINAL GRADE is: "<<std_deviation<<endl<<endl;
  312. break;
  313.  
  314.  
  315. case 8:// Menu Exits
  316. break;
  317. }
  318. }while(w>=1&&w<=8);
  319. }
  320. if(w==8)// if hits 8 goes back to previous menu
  321. break;
  322. }
  323. }
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330. void Modif (double gradeBook[][10], int studentCount)//Function that permits the change student grades and Attendance
  331. {
  332. int i, k, ghj;
  333. if (gradeBook[0][0]==0)//array initialized
  334. {
  335. cout<<"No student were registered"<<endl;
  336. cout<<"Please, refer to option 1."<<endl;
  337. }
  338. else
  339. {
  340. for(i=0; i<studentCount; i++)
  341. {
  342. cout<<"You can Modif the student's grades in the order you entered them, or skip to the other student.\n";
  343. cout<<"Student # " <<i+1<<" ( ID# "<<gradeBook[i][0]<<" )" <<endl<<endl;
  344. do
  345. {
  346. cout<<"Enter 1 to Modify the grade of the first test."<<endl;
  347. cout<<"Enter 2 to Modify the grade of the second test."<<endl;
  348. cout<<"Enter 3 to Modify the grade of the first quiz"<<endl;
  349. cout<<"Enter 4 to Modify the grade of the second quiz."<<endl;
  350. cout<<"Enter 5 to Modify the grade of the project"<<endl;
  351. cout<<"Enter 6 to Modify the grade of the FINAL TEST"<<endl;
  352. cout<<"Enter 7 to Modify the absences."<<endl;
  353. cout<<"Enter 8 to skip this student, or to exit."<<endl<<endl;
  354. k=0;
  355. ghj=0;
  356. cin>>k;
  357. while(k<1||k>8)
  358. {
  359. cout<<"***Invalid Option***\n Please Re-Enter: ";
  360. cin>>k;
  361. }
  362. switch (k)
  363. {
  364. case 1: //each case validates for wrong values and modifies existing values in gradeBook
  365. cout<<"Enter the new score for first test: ";
  366. cin>>ghj;
  367. while(ghj>100||ghj<0)
  368. {
  369. cout<<"***Invalid Grade Value*** Re-Enter: ";
  370. cin>>ghj;
  371. }
  372. gradeBook[i][1]=ghj;
  373. cout<<"New value for grade of the first test is: "<<gradeBook[i][1]<<"%"<<endl<<endl;
  374. break;
  375. case 2:
  376. cout<<"Enter the new score for second test: ";
  377. cin>>ghj;
  378. while(ghj>100||ghj<0)
  379. {
  380. cout<<"***Invalid Grade Value***\n Please Re-Enter: ";
  381. cin>>ghj;
  382. }
  383. gradeBook[i][2]=ghj;
  384. cout<<"New value for grade of the second test is: "<<gradeBook[i][2]<<"%"<<endl<<endl;
  385. break;
  386. case 3:
  387. cout<<"Enter the new score for the first quiz: ";
  388. cin>>ghj;
  389. while(ghj>100||ghj<0)
  390. {
  391. cout<<"***Invalid grade value***\nPlease Re-Enter: ";
  392. cin>>ghj;
  393. }
  394. gradeBook[i][3]=ghj;
  395. cout<<"New value for grade of the first quiz is: "<<gradeBook[i][3]<<"%"<<endl<<endl;
  396. break;
  397. case 4:
  398. cout<<"Enter the new score for the second quiz: ";
  399. cin>>ghj;
  400. while(ghj>100||ghj<0)
  401. {
  402. cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
  403. cin>>ghj;
  404. }
  405. gradeBook[i][4]=ghj;
  406. cout<<"New value for grade of the second quiz is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
  407. break;
  408.  
  409. case 5:
  410. cout<<"Enter the new score for the project: ";
  411. cin>>ghj;
  412. while(ghj>100||ghj<0)
  413. {
  414. cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
  415. cin>>ghj;
  416. }
  417. gradeBook[i][5]=ghj;
  418. cout<<"New value for grade of the project is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
  419. break;
  420.  
  421. case 6:
  422. cout<<"Enter the new score for the FINAL TEST ";
  423. cin>>ghj;
  424. while(ghj>100||ghj<0)
  425. {
  426. cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
  427. cin>>ghj;
  428. }
  429. gradeBook[i][6]=ghj;
  430. cout<<"New value for grade of the FINAL TEST is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
  431. break;
  432.  
  433.  
  434. case 7:
  435. cout<<"Enter the new number of absences: ";
  436. cin>>ghj;
  437. while(ghj>20||ghj<0)//Validation of attendance only twenty classes
  438. {
  439. cout<<"Remember, there are only 20 classes and the value cannot be negative...."<<endl;
  440. cout<<"Please re-enter: ";
  441. cin>>ghj;
  442. }
  443. gradeBook[i][7]=ghj;
  444. cout<<"New value for absences is: "<<gradeBook[i][7]<<endl<<endl;
  445. break;
  446. }
  447. if(k==8)
  448. {
  449. break;
  450. }
  451. }while(k>=1&&k<=7);
  452. }
  453. cout<<"Choose option 2 to calculate the new grades or absences..."<<endl<<endl;
  454. //Then user needs to perform option two in main menu to calculate the new grades based on new data entered
  455. }
  456. }
  457.  
  458.  
  459.  
  460.  
  461.  
  462. void ViewGrades (double gradeBook[][10], int studentCount)//This function show the wholes grade for each student
  463. {
  464. int i, j, k;
  465. double note=0;
  466. char x;
  467. if (gradeBook[0][0]==0)
  468. cout<<"No ID numbers were entered. Select to option 1."<<endl<<endl;
  469. else if(gradeBook[0][10]==-1)
  470. cout<<"No calculations have been made. Select option 2."<<endl<<endl;
  471. else
  472. {
  473. for(i=0; i<studentCount; i++)//Student count
  474. {
  475. for(j=0; j<1; j++)//First row is for ID
  476. {
  477. cout<<"The scores for student's (With ID #: "<<gradeBook[i][j]<<")tests are:\n";
  478. for(k=1; k<7; k++)//GRADES are positions from 1, 2, 3, 4,5, 6,7 of array
  479. cout<<gradeBook[i][k]<<"%"<<endl;
  480. cout<<"With ";
  481. for(k=8; k<9; k++)//Remember position 8 of the array is for the ATTENDANCE
  482. cout<<gradeBook[i][k];
  483. cout<<" absences to class."<<endl;
  484. cout<<"Final grade is ";
  485. if (gradeBook[i][10]<=100&&gradeBook[i][10]>=90)
  486. x='A';// if final avarage is between 90 & 100 it's an A
  487. else if (gradeBook[i][10]<=89&&gradeBook[i][10]>=80)
  488. x='B';// if final avarage is between 80 & 89 it's a B
  489. else if (gradeBook[i][10]<=79&&gradeBook[i][10]>=70)
  490. x='C';// if final avarage is between 70 & 79 it's a C
  491. else if (gradeBook[i][10]<=69&&gradeBook[i][10]>=60)
  492. x='D';// if final avarage is between 60 & 69 it's a B
  493. else
  494. x='F';// If its lower than 59 then it's an F
  495. cout<<x<<"(";
  496. for(k=7; k<8; k++)
  497. cout<<gradeBook[i][10];
  498. cout<<"%)."<<endl<<endl; //prints out final grade letter and percent
  499. }
  500. }
  501. }
  502. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KungFuTze is offline Offline
14 posts
since Aug 2009
Sep 19th, 2009
1

Re: Gradebook Project help c++ with two dimensional arrays

Right off the bat, I see a few problems just in the very beginning:

C++ Syntax (Toggle Plain Text)
  1.  
  2.  
  3.  
  4. #include<iostream> //Librerias
  5. #include<cmath> //Librerias
  6. using namespace std;
  7.  
  8. /* Function prototypes */
  9.  
  10. void Ingrades (double[][10], int); // Function that lets user input student ID, two partial exams one final, two quizzes and one project and studentCount of twenty classes
  11. void Score (double[][10], int);//Score and mean calculations
  12. void Standev (double[][10], int); //Function that calculates standard deviation
  13. void Modif (double [][10], int); //Function that lets user change any student grades for any test and studentCount
  14. void ViewGrades (double[][10], int); //Function that displays the Score of each test for each student and outputs the final grade.
  15. int main ()
  16. {
  17. const int studentCount=15, studentRecords=10;//We initialize arrays to dimensions studentCount is twenty max number of classes and studentRecords fifteen max number of students.
  18. int option, i, studentID;
  19.  
  20. /* MultiDemensional Array : first dimension is fifteen that represents the student count
  21. Second dimension is ten that represents the student records to be modified
  22. zero row represents students ID
  23. rows one to seven represents student grades composed of : two partial tests, two quizzes, one project and one final
  24. row eight represent ABSENCES
  25. row nine represents final grade
  26. */
  27.  
  28. double gradeBook[studentCount][studentRecords];
  29.  
  30.  
  31.  
  32. cout<<" \t \t Student GradeBook "<<endl;
  33.  
  34. cout<<"Enter the amount of the students (1 to 15): ";
  35. cin>>studentID; // asks for total number of students
  36. while(studentID<1 ||studentID>15)//student count is 15
  37. {
  38. cout<<"The student quantity should be from 1 to 15. \nPlease Re-Enter: ";
  39. cin>>studentID;
  40. }
  41. for (i=0; i<studentID; i++)//Array initialized to 0
  42. {
  43. gradeBook[i][0]=0;
  44. gradeBook[i][10]=-1;
  45. }

Line 23 - you have six scores. Why do you have rows 1 through 7 to store them instead of rows 1 - 6?

Line 44 - Valid indexes for the second index are 0 to 9. Using index 10 may or may not be a seg fault, but you shouldn't do that.


As for your problems/questions, you say you are storing absences in index 8 above and that appears to be the case in lines 130 - 141 in your code. What do you mean when you say you aren't sure where you're storing it?

This is a lot of code to go through. Please give us more precise questions to work off of. "I'm having problems" is a bit vague. Test the program, see if it works, and if it doesn't, tell us the exact input you used, the exact output you got, and what the output should have been.
Last edited by VernonDozier; Sep 19th, 2009 at 11:50 am.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,372 posts
since Jan 2008
Sep 21st, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

my main problem is that I really don't grasp how to use multi-dimensional arrays that well, I'm having problem specifically in the part of the Score function and then in the ViewGrades function for example:

I entered grades for 3 students but only two calculations come out ok then third one automatically gives me an F to that student id and if I enter 5 student's records the last student ID will become 0% F



The scores for student's (With ID #: 1)tests are:
100%
100%
100%
100%
100%
100%
With 5 absences to class.
Final grade is A(95%).

The scores for student's (With ID #: 95)tests are:
100%
100%
100%
100%
100%
100%
With 10 absences to class.
Final grade is F(0%).

The scores for student's (With ID #: 0)tests are:
100%
100%
100%
100%
100%
100%
With 0 absences to class.
Final grade is F(0%).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KungFuTze is offline Offline
14 posts
since Aug 2009
Sep 21st, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

This function asks to input all six grades, but given that all grades have the same value.

I'm out of ideas how to ask and store in an array given that each grade has a different value. How would I store for example that test 1 , test 2 are each 20% and quizzes 10% and project 20% and final 30%?


C++ Syntax (Toggle Plain Text)
  1.  
  2. void Ingrades (double gradeBook[][10],int studentCount)//
  3. {
  4. // i represents students count and j represents student data: grades, ID and absent count
  5. int i, j;
  6. for(i=0; i<studentCount; i++)//studentCout initialized to 0
  7. {
  8. for(j=0; j<1; j++)// For repetition cycle that asks for students ID
  9. {
  10. cout<<"Enter the student's ID number: ";
  11. cin>>gradeBook[i][j];
  12. while(gradeBook[i][j]<=0)//Student id cannot be <= 0
  13. {
  14. cout<<"Invalid ID Number. Re-enter again....: ";
  15. cin>>gradeBook[i][j];
  16. }
  17. }
  18. cout<<"Enter in the following order: \n test1 = 1, test2= 2, quiz1= 3, quiz2= 4, project1= 5 FINAL =6"<<endl;
  19.  
  20. for(j=1; j<7; j++)//
  21. {
  22. cout<<"Enter the grades "<<j<<": ";
  23. cin>>gradeBook[i][j];
  24. while(gradeBook[i][j]>100||gradeBook[i][j]<0)// gradeBook validated that grades cannot be lower than zero and greater than a hundred
  25. {
  26. cout<<"INVALID GRADES"<<endl;
  27. cout<<"Please Re-Enter: ";
  28. cin>>gradeBook[i][j];
  29. }
  30. }
  31. for(j=8; j<9; j++)//Counts for Absences
  32. {
  33. cout<<"Enter the student's number of absences (Total of clases: 20): ";
  34. cin>>gradeBook[i][j];
  35. while(gradeBook[i][j]<0||gradeBook[i][j]>20)// while validation Class total is twenty , Absences cannot be more than the total of classes
  36. {
  37. cout<<"**The number of absences exceed the number of classes**"<<endl;
  38. cout<<"Re-enter: ";
  39. cin>>gradeBook[i][j];
  40. }
  41. cout<<endl<<endl;
  42. }
  43. }
  44. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KungFuTze is offline Offline
14 posts
since Aug 2009
Sep 21st, 2009
1

Re: Gradebook Project help c++ with two dimensional arrays

My first thought is : use a StudentGrades struct and an array of such structures; it will make the whole thing readable at least

But let's see what should happen here in the "Ingrade" function ( wierd name by the way ).
You say: "// Function that lets user input student ID, two partial exams one final, two quizzes and one project and studentCount of twenty classes"

If i get this right, you want the user to give you "n" students, their grades & their absences ? And you want to save this info in the 2D array ?

You should do this in a single go like this:

C++ Syntax (Toggle Plain Text)
  1. // ! All this assumes that you have an array big enough to hold "n" arrays of 8 int positions !
  2. char * gradeType[6] = {"test1", "test2", "quiz1", "quiz2", "project", "Final"};
  3. for(int i = 0; i < studentCount; i++)
  4. {
  5. cout << "Enter the student's ID number: ";
  6. cin >> gradeBook[i][0];
  7.  
  8. for(int j = 1; j < 7/*number of grades + 1 because at position [0] you stored the ID*/; j++)
  9. {
  10. cout << "Enter grade for " << gradeType[j-1] << ": ";
  11. cin >> gradeBook[i][j];
  12. }
  13.  
  14. cout << "Enter the student's absence count: ";
  15. cin >> gradeBook[i][7];
  16. }
Reputation Points: 12
Solved Threads: 4
Light Poster
vali82 is offline Offline
32 posts
since Aug 2009
Sep 21st, 2009
1

Re: Gradebook Project help c++ with two dimensional arrays

You must fix that bad index problem for this program to work. You can't use 10 as the second index. Valid indexes are 0 through 9. If you use 10, even if it compiles and runs, it almost certainly is overwriting information that you don't want it to overwrite, which makes your program unpredictable.

Run this program to get a sense of what I mean:

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a[15][10];
  7. a[1][0] = 6;
  8. a[0][10] = 9;
  9.  
  10. cout << a[1][0] << endl;
  11. return 0;
  12. }

Result? You get a display of 9, which means the 6 was written over. Why? Because I used an invalid index and therefore a[1][0] and a[0][10] both point to the same address.

So you have two choices:
  1. Change your array declaration to double gradeBook[studentCount][studentRecords+1] so that legal second indexes are 0 through 10, not 0 through 9.
  2. Go through your code and make sure nothing is stored where the second index is 10.

The first solution is much quicker. Try it. Perhaps the problem will go away.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,372 posts
since Jan 2008
Sep 21st, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

Note that if you elect to use my first option in the prior post, you must change declarations like this:

C++ Syntax (Toggle Plain Text)
  1. void Ingrades (double gradeBook[][10],int studentCount)

to

C++ Syntax (Toggle Plain Text)
  1. void Ingrades (double gradeBook[][11],int studentCount)


so they match the original array declaration. Otherwise all offset calculations will be incorrect.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,372 posts
since Jan 2008
Sep 22nd, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

Ok, I've been doing some modifications on my code and everything but the modif function works ok. The modif function although it runs and compiles. It actually does nothing to the original array thus I cannot recalculate scores based on the new scores entered. any help? How would I send the values asked from the modif function to the original array stored by the Ingrades function ? o.O .


C++ Syntax (Toggle Plain Text)
  1.  
  2. #include<iostream>
  3. #include<cmath>
  4. using namespace std;
  5.  
  6. void Ingrades (double[][9], int);
  7. void Score (double[][9], int);
  8. void Standev (double[][9], int);
  9. void Modif (double [][9], int);
  10. void ViewGrades (double[][9], int);
  11. int main ()
  12. {
  13. const int Students=15, records=9;
  14. int option, i, student;
  15.  
  16. double gradebook[Students][records];
  17.  
  18. cout<<"**********Students' grade book***********\n";
  19. cout<<"Enter the amount of students";
  20. cin>>student;
  21. while(student<1||student>15)
  22. {
  23. cout<<"Student must be 1 to 15,please re-enter";
  24. cin>>student;
  25. }
  26. for (i=0; i<student;i++)
  27. {
  28. gradebook[i][0]=0;
  29. gradebook[i][8]=-1;
  30. }
  31. do
  32. {
  33. option=0;
  34. cout<<"1.Enter the students grade, (two partial exam and one final, quizes and project) and attendence to class"<<endl;
  35. cout<<"2.Compute each student score and final grade"<<endl;
  36. cout<<"3.Compute the variance and standard deviation of the exams and final score"<<endl;
  37. cout<<"4.Modify grade"<<endl;
  38. cout<<"5.List of students' grade"<<endl;
  39. cout<<"6.FINISH"<<endl;
  40. cout<<"Choose an option";
  41. cin>>option;
  42. cout<<endl;
  43. while(option<1||option>6)//un while para validar
  44. {
  45. cout<<"*****ERROR,ERROR*****"<<endl;
  46. cout<<"Please, re-enter the option";
  47. cin>>option;
  48. }
  49. switch (option)//Se empiesan a editar los cases
  50. {
  51. case 1:
  52. if(gradebook[0][0]!=0)//Obviamente ya un veaz hayas registrado estudiantes no podras hacerlo de nuevo por eso creamos este IF
  53. {
  54. cout<<"This process can't be done again."<<endl;
  55. cout<<"Select options 2-6."<<endl<<endl;
  56. }
  57. else
  58. Ingrades(gradebook, student);
  59. break;
  60. case 2:
  61. Score(gradebook, student);
  62. break;
  63. case 3:
  64. Standev(gradebook, student);
  65. break;
  66. case 4:
  67. Modif(gradebook, student);
  68. case 5:
  69. ViewGrades(gradebook, student);
  70. break;
  71. case 6:
  72. cout<<"~~~~~~~~~~THANKS FOR USING STUDENTS' GRADE BOOK~~~~~~~~~~"<<endl<<endl;
  73. break;
  74. }
  75. }while(option>=1&&option<=5);
  76. return 0;
  77.  
  78. }
  79. void Ingrades (double gradebook[][9],int Students)
  80. {
  81. int i, j;
  82. for(i=0;i<Students;i++)
  83. {
  84. for(j=0;j<1;j++)
  85. {
  86. cout<<"Enter students' ID#";
  87. cin>>gradebook[i][j];
  88. while(gradebook[i][j]<=0)
  89. {
  90. cout<<"***Invalid ID Number***. Re-enter again";
  91. cin>>gradebook[i][j];
  92. }
  93. }
  94. for(j=1;j<7;j++)
  95. {
  96. if(j=1)
  97. {
  98. cout<<"Enter exam 1:";
  99. cin>>gradebook[i][j];
  100. }
  101. while(gradebook[i][j]>100||gradebook[i][j]<0)
  102. {
  103. cout<<"***Invalid grade***"<<endl;
  104. cout<<"Please Re-Enter";
  105. cin>>gradebook[i][j];
  106. }
  107.  
  108. if(j=2)
  109. {
  110. cout<<"Enter exam 2:";
  111. cin>>gradebook[i][j];
  112. }
  113. while(gradebook[i][j]>100||gradebook[i][j]<0)
  114. {
  115. cout<<"***Invalid grade***"<<endl;
  116. cout<<"Please Re-Enter";
  117. cin>>gradebook[i][j];
  118. }
  119. if(j=3)
  120. {
  121. cout<<"Enter final exam:";
  122. cin>>gradebook[i][j];
  123. }
  124. while(gradebook[i][j]>100||gradebook[i][j]<0)
  125. {
  126. cout<<"***Invalid grade***"<<endl;
  127. cout<<"Please Re-Enter";
  128. cin>>gradebook[i][j];
  129. }
  130. if(j=4)
  131. {
  132. cout<<"Enter quiz 1:";
  133. cin>>gradebook[i][j];
  134. }
  135. while(gradebook[i][j]>100||gradebook[i][j]<0)
  136. {
  137. cout<<"***Invalid grade***"<<endl;
  138. cout<<"Please Re-Enter";
  139. cin>>gradebook[i][j];
  140. }
  141. if(j=5)
  142. {
  143. cout<<"Enter quiz 2:";
  144. cin>>gradebook[i][j];
  145. }
  146. while(gradebook[i][j]>100||gradebook[i][j]<0)
  147. {
  148. cout<<"***Invalid grade***"<<endl;
  149. cout<<"Please Re-Enter";
  150. cin>>gradebook[i][j];
  151. }
  152. if(j=6)
  153. {
  154. cout<<"Enter the proyect:";
  155. cin>>gradebook[i][j];
  156. }
  157. while(gradebook[i][j]>100||gradebook[i][j]<0)
  158. {
  159. cout<<"***Invalid grade***"<<endl;
  160. cout<<"Please Re-Enter";
  161. cin>>gradebook[i][j];
  162. }
  163. }
  164. for(j=7;j<8;j++)
  165. {
  166. cout<<"Enter students' abscence";
  167. cin>>gradebook[i][j];
  168. while(gradebook[i][j]<0||gradebook[i][j]>20)
  169. {
  170. cout<<"**The number of abscences exceed the number of classes**"<<endl;
  171. cout<<"Re-enter: ";
  172. cin>>gradebook[i][j];
  173. }
  174. cout<<endl<<endl;
  175. }
  176. }
  177. }
  178. void Score(double gradebook[][9], int Students)
  179. {
  180. int i, j;
  181. for (i=0; i<Students; i++)
  182. {
  183. if (gradebook[i][0]==0)
  184. {
  185. cout<<"***No students were registered***.";
  186. cout<<"Select Option 1."<<endl;
  187. break;
  188. }
  189. else
  190. {
  191. for (i=0; i<Students; i++)
  192. {
  193. gradebook[i][8]=(gradebook[i][1]*0.15)+(gradebook[i][2]*0.15)+(gradebook[i][3]*0.30)+(gradebook[i][4]*0.10)+(gradebook[i][5]*0.10)+(gradebook[i][6]*0.20);
  194. }
  195. for (i=0; i<Students; i++)
  196. {
  197. if(gradebook[i][7]>=10)
  198. gradebook[i][8]=0;
  199. else
  200. {
  201. for(i=0; i<Students; i++)
  202. {
  203. for(j=0;j<gradebook[i][7];j++)
  204. {
  205. gradebook[i][8]-=1.0;
  206. }
  207. if(gradebook[i][8]<0)
  208. gradebook[i][8]=0;
  209. }
  210. }
  211. }
  212. }
  213. cout<<"***************ALL CALCULATION ARE MADE***************"<<endl<<endl;
  214. }
  215. }
  216.  
  217.  
  218.  
  219.  
  220. void Standev (double gradebook[][9], int Students)
  221. {
  222. int i, j, a, x;
  223. double sum, promedio, rum, letra, std_deviation;
  224. for(a=0; a<Students; a++)
  225. {
  226. if (gradebook[0][0]==0)
  227. {
  228. cout<<"No Grades were registered."<<endl;
  229. cout<<"Select Option 1."<<endl;
  230. break;
  231. }
  232. else if(gradebook[0][8]==-1)
  233. {
  234. cout<<"No calculations have been made nor grades were registrered."<<endl;
  235. cout<<"Select Option 2."<<endl<<endl<<endl;
  236. break;
  237. }
  238. else
  239. {
  240. do
  241. {
  242. cout<<"1.See the variance and standard deviation of the first exam."<<endl;
  243. cout<<"2.See the variance and standard deviation of the second exam."<<endl;
  244. cout<<"3.See the variance and standard deviation of the final exam."<<endl;
  245. cout<<"4.See the variance and standard deviation of the first quiz."<<endl;
  246. cout<<"5.See the variance and standard deviation of the second quiz."<<endl;
  247. cout<<"6.See the variance and standard deviation of the proyect."<<endl;
  248. cout<<"8.EXIT"<<endl;
  249. sum=0;
  250. rum=0;
  251. promedio;
  252. letra=0;
  253. std_deviation=0;
  254. x=0;
  255. cin>>x;
  256. while(x<1||x>8)
  257. {
  258. cout<<"***Error***Re-Enter.";
  259. cin>>x;
  260. }
  261. switch (x)
  262. {
  263. case 1:
  264. for(i=0; i<Students; i++)
  265. for(j=1; j<2; j++)
  266. sum+=gradebook[i][j];
  267. promedio=sum/Students;
  268. for(i=0; i<Students; i++)
  269. for(j=1; j<2; j++)
  270. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  271. letra=rum/(Students-1);
  272. std_deviation=sqrt(letra);
  273. cout<<"Variance of first test is_"<<letra<<endl;
  274. cout<<"Standard deviation of first test is_"<<std_deviation<<endl<<endl;
  275. break;
  276. case 2:
  277. for(i=0; i<Students; i++)
  278. for(j=2; j<3; j++)
  279. sum+=gradebook[i][j];
  280. promedio=sum/Students;
  281. for(i=0; i<Students; i++)
  282. for(j=2; j<3; j++)
  283. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  284. letra=rum/(Students-1);
  285. std_deviation=sqrt(letra);
  286. cout<<"Variance of second test is_"<<letra<<endl;
  287. cout<<"Standard deviation of second test is_"<<std_deviation<<endl<<endl;
  288. break;
  289. case 3:
  290. for(i=0; i<Students; i++)
  291. for(j=3; j<4; j++)
  292. sum+=gradebook[i][j];
  293. promedio=sum/Students;
  294. for(i=0; i<Students; i++)
  295. for(j=3; j<4; j++)
  296. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  297. letra=rum/(Students-1);
  298. std_deviation=sqrt(letra);
  299. cout<<"Variance of final test is_"<<letra<<endl;
  300. cout<<"Standard deviation of final test is_"<<std_deviation<<endl<<endl;
  301. break;
  302. case 4:
  303. for(i=0; i<Students; i++)
  304. for(j=4; j<5; j++)
  305. sum+=gradebook[i][j];
  306. promedio=sum/Students;
  307. for(i=0; i<Students; i++)
  308. for(j=4; j<5; j++)
  309. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  310. letra=rum/(Students-1);
  311. std_deviation=sqrt(letra);
  312. cout<<"Variance of first quiz is_"<<letra<<endl;
  313. cout<<"Standard deviation of first quiz is_"<<std_deviation<<endl<<endl;
  314. break;
  315. case 5:
  316. for(i=0; i<Students; i++)
  317. for(j=5; j<6; j++)
  318. sum+=gradebook[i][j];
  319. promedio=sum/Students;
  320. for(i=0; i<Students; i++)
  321. for(j=5; j<6; j++)
  322. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  323. letra=rum/(Students-1);
  324. std_deviation=sqrt(letra);
  325. cout<<"Variance of second quiz is_"<<letra<<endl;
  326. cout<<"Standard deviation of second quiz is_"<<std_deviation<<endl<<endl;
  327. break;
  328. case 6:
  329. for(i=0; i<Students; i++)
  330. for(j=6; j<7; j++)
  331. sum+=gradebook[i][j];
  332. promedio=sum/Students;
  333. for(i=0; i<Students; i++)
  334. for(j=6; j<7; j++)
  335. rum+=(gradebook[i][j]-promedio)*(gradebook[i][j]-promedio);
  336. letra=rum/(Students-1);
  337. std_deviation=sqrt(letra);
  338. cout<<"Variance of proyect is_"<<letra<<endl;
  339. cout<<"Standard deviation of proyect is_"<<std_deviation<<endl<<endl;
  340. break;
  341. //default:
  342. //cout<<"INVALID SELECTION"<<endl;
  343. case 7: cout<<"EXIT"<<endl;
  344.  
  345. break;
  346.  
  347. default: cout<<"Invalid Selection"<<endl;
  348. }
  349. }
  350. while(x>=1&&x<=7);
  351. }
  352.  
  353. }
  354. }
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362. void Modif (double gradebook[][9], int Students)
  363. {
  364. int i, y, ng;
  365. if (gradebook[0][0]==0)//Nuevamente tiene que haber registrado notas para que esta funcion trabaje
  366. {
  367. cout<<"No student were registered"<<endl;
  368. cout<<"Please, select option 1."<<endl;
  369. }
  370. else
  371. {
  372. for(i=0; i<Students; i++)
  373. cout<<"Modify the student's grades in the order you entered them, or skip to other student.\n";
  374. cout<<"Student #" <<i+1<<"(ID# "<<gradebook[i][0]<<" )" <<endl<<endl;
  375. do
  376. {
  377. cout<<"1.Modify the grade of the first test."<<endl;
  378. cout<<"2.Modify the grade of the second test."<<endl;
  379. cout<<"3.Modify the grade of quiz 1."<<endl;
  380. cout<<"4.Modify the grade of quiz 2."<<endl;
  381. cout<<"5.Modify the grade of the project."<<endl;
  382. cout<<"6.Modify the grade of the FINAL TEST."<<endl;
  383. cout<<"7.Modify the absences."<<endl;
  384. cout<<"8.Skip this student, or to exit."<<endl<<endl;
  385. y=0;
  386. ng=0;
  387. cin>>y;
  388. while(y<1||y>8)
  389. {
  390. cout<<"***Invalid Option***\n Please Re-Enter: ";
  391. cin>>y;
  392. }
  393. switch (y)
  394. {
  395. case 1:
  396. cout<<"Enter new score for first test: ";
  397. cin>>ng;
  398. while(ng>100||ng<0)
  399. {
  400. cout<<"**Can't compute** Re-Enter: ";
  401. cin>>ng;
  402. }
  403. gradebook[i][1]=ng;
  404. cout<<"New value of the first test is: "<<gradebook[i][1]<<"%"<<endl<<endl;
  405. break;
  406. case 2:
  407. cout<<"Enter new score for second test: ";
  408. cin>>ng;
  409. while(ng>100||ng<0)
  410. {
  411. cout<<"**Can't compute** Re-Enter: ";
  412. cin>>ng;
  413. }
  414. gradebook[i][2]=ng;
  415. cout<<"New value of the second test is: "<<gradebook[i][2]<<"%"<<endl<<endl;
  416. break;
  417. case 3:
  418. cout<<"Enter new score for quiz 1: ";
  419. cin>>ng;
  420. while(ng>100||ng<0)
  421. {
  422. cout<<"**Can't compute** Re-Enter: ";
  423. cin>>ng;
  424. }
  425. gradebook[i][3]=ng;
  426. cout<<"New value of quiz 1 is: "<<gradebook[i][3]<<"%"<<endl<<endl;
  427. break;
  428.  
  429. case 4:
  430. cout<<"Enter new score for quiz 2: ";
  431. cin>>ng;
  432. while(ng>100||ng<0)
  433. {
  434. cout<<" **Can't compute** Re-Enter: ";
  435. cin>>ng;
  436. }
  437. gradebook[i][4]=ng;
  438. cout<<"New value of quiz 2 is: "<<gradebook[i][4]<<"%"<<endl<<endl;
  439. break;
  440.  
  441. case 5:
  442.  
  443. cout<<"Enter new score for project: ";
  444. cin>>ng;
  445. while(ng>100||ng<0)
  446. {
  447. cout<<" **Can't compute** Re-Enter: ";
  448. cin>>ng;
  449. }
  450. gradebook[i][5]=ng;
  451. cout<<"New value of project: "<<gradebook[i][5]<<"%"<<endl<<endl;
  452. break;
  453.  
  454. case 6:
  455. cout<<"Enter new score for FINAL TEST ";
  456. cin>>ng;
  457. while(ng>100||ng<0)
  458. {
  459. cout<<" **Can't compute** Re-Enter: ";
  460. cin>>ng;
  461. }
  462. gradebook[i][6]=ng;
  463. cout<<"New value of FINAL TEST: "<<gradebook[i][6]<<"%"<<endl<<endl;
  464. break;
  465.  
  466. case 7:
  467. cout<<"Enter new number of absences: ";
  468. cin>>ng;
  469. while(ng>20||ng<0)
  470. {
  471. cout<<"*******INCORRECT*******"<<endl;
  472. cout<<"Please re-enter: ";
  473. cin>>ng;
  474. }
  475. gradebook[i][7]=ng;
  476. cout<<"New value for absences is: "<<gradebook[i][7]<<endl<<endl;
  477. break;
  478. }
  479. if(y==8)
  480. {
  481. break;
  482. }
  483. }while(y>=1&&y<=7);
  484. }
  485. cout<<"Choose option 2 to calculate the new grades or abscents"<<endl<<endl;
  486.  
  487. }
  488.  
  489.  
  490.  
  491. void ViewGrades (double gradebook[][9], int Students)
  492. {
  493. int i, j, k;
  494. double note=0;
  495. char x;
  496. if (gradebook[0][0]==0)
  497. cout<<"ID numbers were not entered. Select to option 1."<<endl<<endl;
  498. else if(gradebook[0][8]==-1)
  499. cout<<"Calculations haven't been made. Select option 2."<<endl<<endl;
  500. else
  501. {
  502. for(i=0; i<Students; i++)
  503. {
  504. for(j=0; j<1; j++)
  505. {
  506. cout<<"The scores for student's tests are:\n";
  507. for(k=1; k<7; k++)
  508. cout<<gradebook[i][k]<<"%"<<endl;
  509. cout<<"With ";
  510. for(k=7; k<8; k++)
  511. cout<<gradebook[i][k];
  512. cout<<"Abscences to class."<<endl;
  513. cout<<"Final grade is";
  514. if (gradebook[i][8]<=100&&gradebook[i][8]>=90)
  515. x='A';
  516. else if (gradebook[i][8]<=89&&gradebook[i][8]>=80)
  517. x='B';
  518. else if (gradebook[i][8]<=79&&gradebook[i][8]>=70)
  519. x='C';
  520. else if (gradebook[i][8]<=69&&gradebook[i][8]>=60)
  521. x='D';
  522. else
  523. x='F';
  524. cout<<x<<"(";
  525. for(k=9; k<10; k++)
  526. cout<<gradebook[i][8];
  527. cout<<"%)."<<endl<<endl;
  528. }
  529. }
  530. }
  531. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KungFuTze is offline Offline
14 posts
since Aug 2009
Sep 22nd, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

First of all what scope is your gradebook[][] array declared in?

Try putting this for your Modif() function:
C++ Syntax (Toggle Plain Text)
  1. void *Modif (double gradebook[][9], int Students)
Not 100% sure if that will even do anything but I think it might change your array.
Reputation Points: 164
Solved Threads: 98
Practically a Master Poster
sfuo is offline Offline
642 posts
since Jul 2009
Sep 22nd, 2009
0

Re: Gradebook Project help c++ with two dimensional arrays

The scope of the array is just fine and it gets passed by addres so you're fine there too ...

DO NOT return void * ... why would you do that ? ( as the last post said)

My suggestion is that the "mechanics" are fine but the "logic" part may be faulty; try running it step-by-step in the debugger and check which condition is wrong.
Reputation Points: 12
Solved Threads: 4
Light Poster
vali82 is offline Offline
32 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Vector/Classes help please!! URGENT :(
Next Thread in C++ Forum Timeline: C++ help please !!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC