Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. //
  2. // Calculate grades using the kinder curve
  3. // Formula: f(x)=x+a(100-x)
  4. //
  5. //
  6. //
  7.  
  8. #include <iostream>
  9. #include <fstream>
  10. #include <iomanip>
  11. #include <cstdlib>
  12. #include <string>
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17. const string DASHESLINE = "________________________________________________";
  18. ifstream gradesin;
  19. ofstream gradesout;
  20. int VTID;
  21. string name,
  22. kinder,
  23. alpha,
  24. dummy,
  25. dummy2;
  26. int WHwQ, // Introducing the weighted values signified by putting "W" in front of the grade
  27. WT1,
  28. WT2,
  29. WFin,
  30. WP1,
  31. WP2,
  32. WP3,
  33. WP4,
  34. WP5,
  35. WP6,
  36. HwQ, // Introducing values for each part of grades
  37. T1,
  38. T2,
  39. Fin,
  40. P1,
  41. P2,
  42. P3,
  43. P4,
  44. P5,
  45. P6,
  46. xHwQ,
  47. xT1,
  48. xT2,
  49. xFin,
  50. xP1,
  51. xP2,
  52. xP3,
  53. xP4,
  54. xP5,
  55. xP6,
  56. x; // grade
  57. double c, //curved grade
  58. xc, // percentage curve
  59. px, // percentage uncurve
  60. a; // Krider value
  61.  
  62. gradesout.open("gradesout.txt");
  63. gradesout << fixed << setprecision(0) << noshowpoint;
  64. gradesin.open("gradesin.txt");
  65.  
  66. // line skipping
  67. gradesin.ignore(1500, '\n');
  68. gradesin.ignore(1500,'\n');
  69.  
  70. //read file
  71. gradesin >> WHwQ >> WT1 >> WT2 >> WFin >> WP1 >> WP2 >> WP3 >> WP4 >> WP5 >> WP6 >> dummy >> dummy2;
  72. gradesin >> kinder >> alpha >> a;
  73. gradesin.ignore(1500,'\n');
  74. gradesin >> VTID >> name >> HwQ >> T1 >> T2 >> Fin >> P1 >> P2 >> P3 >> P4 >> P5 >> P6;
  75. gradesout << "Dwight Barnette" << '\n' << "Student Score/Curve" << '\n' << '\n' << DASHESLINE << '\n' << "Name" << '\t' << '\t' << "Score" << '\t' << "Curve" << '\t' << '\n' << name << '\t' << px << '\t' << xc << '\n' << '\n' << DASHESLINE; // header for grades out file
  76. while (gradesin)
  77. {
  78. if (WHwQ+WT1+WT2+WFin+WP1+WP2+WP3+WP4+WP5+WP6 != 100)
  79. {
  80. cout << "Grade values does equal 100%" << endl;
  81. gradesout << "Grade value does not equal 100%" << endl;
  82. return 0;
  83. }
  84. else
  85. {
  86. xHwQ = HwQ*WHwQ;
  87. xT1 = T1*WT1;
  88. xT2 = T2*WT2;
  89. xFin = Fin*WFin;
  90. xP1 = P1*WP1;
  91. xP2 = P2*WP2;
  92. xP3 = P3*WP3;
  93. xP4 = P4*WP4;
  94. xP5 = P5*WP5;
  95. xP6 = P6*WP6;
  96. x = xHwQ+xT1+xT2+xFin+xP1+xP2+xP3+xP4+xP5+xP6;
  97. px = x*(.01);
  98. c = x+a*(100-x);
  99. xc = c *(.01);
  100. }// end else
  101. }//end while
  102. gradesin.close();
  103. gradesout.close();
  104. return 0;
  105.  
  106. }// end of main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement