Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. Description: Write a program that calculates your percentage based on your grades/points possible.
  2. Must be flexible as far as number of assignments goes.
  3. */
  4.  
  5.  
  6. #include <iostream>
  7. using namespace std;
  8.  
  9.  
  10. int main ()
  11.  
  12. {
  13. int n=0,n_initial; // n will be the number of assignments entered in the system.
  14. // since n will be counting down, I want to save n_initial as well.
  15.  
  16. // # OF EXERCISES
  17. cout << "How many exercises to input? > ";
  18. cin >> n;
  19. n_initial = n;
  20.  
  21. int grades [2][n]; // 2 rows for possible and actual, n columns because you will have a column for each item.
  22.  
  23.  
  24.  
  25. //SCORE RECIEVED COUNTDOWN
  26. while (n>0)
  27.  
  28. {
  29. int x,y;
  30. cout << endl << endl << "Score recieved for exercise " << n << ": ";
  31. cin >> x;
  32. grades [0][n] = x;
  33. cout << endl << "Points possible for exercise " << n << ": ";
  34. cin >> y;
  35. grades [1][n] = y;
  36.  
  37. n = n-1;
  38. }
  39.  
  40. //CALCULATION OF TOTAL AND PERCENT
  41. double score_total=0,pointspossible_total=0,rows_1,rows_2;
  42.  
  43. //SCORE TOTAL
  44. int xy=0;
  45. n = n_initial;
  46.  
  47. for (int xy=0; xy < n_initial; xy++)
  48. {
  49. score_total += grades [0][n];
  50. n--;
  51. }
  52. cout << endl << "Score Total = "<< score_total << endl;
  53.  
  54. //POINTS POSSIBLE TOTAL
  55. xy=0;
  56. n = n_initial;
  57.  
  58. for (int xy=0; xy < n_initial; xy++)
  59. {
  60. pointspossible_total += grades [1][n];
  61. n--;
  62. }
  63. cout << "Possible points Total = " << pointspossible_total << endl;
  64. cout << "Your total is " << score_total << " out of " << pointspossible_total << ", and your percentage is " << (score_total/pointspossible_total)*100 << "%" <<endl;
  65. system ("pause");
  66. return (0);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement