Advertisement
Guest User

dat

a guest
Jan 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <stdlib.h>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8. class validation
  9. {
  10. public:
  11. bool test_PAC(int PAC_no1, int PAC_no2, int PAC_no3, int Input_PAC1, int Input_PAC2, int Input_PAC3);
  12. bool validate_exam_mark(float mark);
  13. bool validate_user_id(int user_id);
  14. bool validate_PAC(int PAC);
  15. private:
  16. int dm_PAC1;
  17. int dm_PAC2;
  18. int dm_PAC3;
  19. int dm_Input_PAC1;
  20. int dm_Input_PAC2;
  21. int dm_Input_PAC3;
  22. int dm_user_id;
  23. float dm_mark;
  24. };
  25.  
  26. bool validation::validate_exam_mark(float mark)
  27. {
  28. dm_mark = mark;
  29. if(dm_mark <1 || dm_mark >100)
  30. {
  31. return false;
  32. }
  33. else
  34. {
  35. return true;
  36. }
  37. }
  38.  
  39. class results: public validation
  40. {
  41. public:
  42. void display_headings();
  43. string get_LC_marks(float p_mark);
  44. int get_LC_points( string p_grade);
  45. private:
  46. string dm_grade;
  47. int dm_cao;
  48. float dm_mark;
  49. };
  50.  
  51. string results::get_LC_marks(float p_mark)
  52. {
  53. dm_mark = p_mark;
  54. if ( dm_mark >= 90 && dm_mark <= 100)
  55. {
  56. dm_grade = "H1";
  57. }
  58. return "H1";
  59.  
  60. if ( dm_mark >=80 && dm_mark <= 90)
  61. {
  62. dm_grade = "H2";
  63. }
  64. return "H2";
  65.  
  66. if ( dm_mark >=70 && dm_mark <= 80)
  67. {
  68. dm_grade = "H3";
  69. }
  70. return "H3";
  71.  
  72. if ( dm_mark >=60 && dm_mark <= 70)
  73. {
  74. dm_grade = "H4";
  75. }
  76. return "H4";
  77.  
  78. if ( dm_mark >=50 && dm_mark <= 60)
  79. {
  80. dm_grade = "H5";
  81. }
  82. return "H5";
  83.  
  84. if ( dm_mark >=40 && dm_mark <= 50)
  85. {
  86. dm_grade = "H6";
  87. }
  88. return "H6";
  89.  
  90. if ( dm_mark >=30 && dm_mark <= 40)
  91. {
  92. dm_grade = "H7";
  93. }
  94. return "H7";
  95.  
  96. if ( dm_mark > 30 )
  97. {
  98. dm_grade = "H8";
  99. }
  100. return "H8";
  101. };
  102.  
  103. int results::get_LC_points(string p_grade)
  104. {
  105. dm_grade = p_grade;
  106. if(dm_grade == "H1")
  107. {
  108. dm_cao = 100;
  109. }
  110. return 100;
  111.  
  112. if(dm_grade == "H2")
  113. {
  114. dm_cao = 88;
  115. }
  116. return 88;
  117.  
  118. if(dm_grade == "H3")
  119. {
  120. dm_cao = 77;
  121. }
  122. return 77;
  123.  
  124. if (dm_grade == "H4")
  125. {
  126. dm_cao = 66;
  127. }
  128. return 66;
  129.  
  130. if (dm_grade == "H5")
  131. {
  132. dm_cao = 56;
  133. }
  134. return 56;
  135.  
  136. if (dm_grade == "H6")
  137. {
  138. dm_cao = 46;
  139. }
  140. return 46;
  141.  
  142. if (dm_grade == "H7")
  143. {
  144. dm_cao = 37;
  145. }
  146. return 37;
  147.  
  148. if (dm_grade == "H8")
  149. {
  150. dm_cao = 0;
  151. }
  152. return 0;
  153. }
  154.  
  155. bool validation::validate_user_id(int user_id)
  156. {
  157. dm_user_id = user_id;
  158. dm_user_id = 12345678;
  159. if(dm_user_id == 0 )
  160. {
  161. return false;
  162. }
  163. else
  164. {
  165. return true;
  166. }
  167. }
  168.  
  169. bool validation::test_PAC(int PAC_no1,int PAC_no2,int PAC_no3, int Input_PAC1,int Input_PAC2,int Input_PAC3) /// WORKING 18/01/2017
  170. {
  171. dm_PAC1 = PAC_no1;
  172. dm_Input_PAC1 = Input_PAC1;
  173. if ((dm_PAC1 == 1 && dm_Input_PAC1 != 9) || (dm_PAC1 == 2 && dm_Input_PAC1 != 9 )
  174. || (dm_PAC1 == 3 && dm_Input_PAC1 != 8 ) || (dm_PAC1 == 4 && dm_Input_PAC1 != 8 )
  175. || (dm_PAC1 == 5 && dm_Input_PAC1 != 1 ) )
  176. {
  177. return false;
  178. }
  179. else
  180. {
  181. return true;
  182. }
  183. dm_PAC2 = PAC_no2;
  184. dm_Input_PAC2 = Input_PAC2;
  185. if ((dm_PAC2 == 1 && dm_Input_PAC2 != 9) || (dm_PAC2 == 2 && dm_Input_PAC2 != 9 )
  186. || (dm_PAC2 == 3 && dm_Input_PAC2 != 8 ) || (dm_PAC2 == 4 && dm_Input_PAC2 != 8 )
  187. || (dm_PAC2 == 5 && dm_Input_PAC2 != 1 ) )
  188. {
  189. return false;
  190. }
  191. else
  192. {
  193. return true;
  194. }
  195.  
  196. dm_PAC3 = PAC_no3;
  197. dm_Input_PAC3 = Input_PAC3;
  198. if ((dm_PAC3 == 1 && dm_Input_PAC3 != 9) || (dm_PAC3 == 2 && dm_Input_PAC3 != 9 )
  199. || (dm_PAC3 == 3 && dm_Input_PAC3 != 8 ) || (dm_PAC3 == 4 && dm_Input_PAC3 != 8 )
  200. || (dm_PAC3 == 5 && dm_Input_PAC3 != 1 ) )
  201. {
  202. return false;
  203. }
  204. else
  205. {
  206. return true;
  207. }
  208.  
  209.  
  210. }
  211.  
  212. const int No_of_students = 6;
  213. const int No_of_subjects = 6;
  214. int lc_results[No_of_students] [No_of_subjects] =
  215. {100,85,75,65,55,45,
  216. 60,80,75,50,60,75,
  217. 90,90,90,90,90,90,
  218. 60,68,75,50,60,55,
  219. 60,73,75,50,50,75,
  220. 60,75,75,50,50,65};
  221. string grade_table [6][6];
  222. int points_table [6][6];
  223. int row_average, row_total;
  224. string sub_name[6] = {"English", "Maths", "Physics", "French" ,"History"};
  225. string student_name[6] = {"T Jones", "G Addams", "E Kenny", "T May", "B Behan", "D Breen" };
  226.  
  227.  
  228.  
  229.  
  230. int pac1, pac2 , pac3;
  231. int user_pac1,user_pac2, user_pac3;
  232. int user_id1;
  233. int Yes_Or_No1, Yes_Or_No2;
  234. int main()
  235. {
  236. class validation user1;
  237.  
  238. cout << time(0) << endl ; /// no of seconds since 01011970
  239. start: srand (time (0)); /// use time(0) as seed value
  240. pac1 = 1+ (rand()%5); /// use rand to generate an integer 1 or 2 or 3 or 4 or 5
  241. start2:
  242. pac2 = 1+ (rand()%5);
  243. if(pac2 == pac1)
  244. {
  245. goto start2;
  246. }
  247. start3:
  248. pac3 = 1+ (rand()%5);
  249. if(pac3 == pac2 || pac3 == pac1)
  250. {
  251. goto start3;
  252. }
  253.  
  254. cout << " Enter your User Id :" << endl;
  255. cin >> user_id1;
  256. cout << " " << endl;
  257. cout << " " << endl;
  258.  
  259. cout << "Enter PAC " << pac1 << " :" ; /// Prompt user for PAC no ?
  260. cin >> user_pac1; /// User enters correct PAC
  261. cout << " " << endl;
  262. cout << " " << endl;
  263. cout << "Enter PAC " << pac2 << " :" ; /// Prompt user for PAC no ?
  264. cin >> user_pac2;
  265. cout << " " << endl;
  266. cout << " " << endl;
  267. cout << "Enter PAC " << pac3 << " :" ; /// Prompt user for PAC no ?
  268. cin >> user_pac3;
  269. cout << " " << endl;
  270. cout << " " << endl;
  271.  
  272.  
  273. Yes_Or_No1 = user1.test_PAC(pac1,pac2,pac3,user_pac1,user_pac2,user_pac3);
  274.  
  275.  
  276. Yes_Or_No2 = user1.validate_user_id(user_id1);
  277.  
  278.  
  279. if(Yes_Or_No1 == 1 && Yes_Or_No2 == 1)
  280. {
  281. cout << " " << endl;
  282. cout << "Valid User !!!" << endl;
  283. cout << " " << endl;
  284. }
  285. else
  286. {
  287. cout << " " << endl;
  288. cout << "Invalid User !!!" << endl;
  289. cout << " " << endl;
  290. }
  291.  
  292. class results::results student[6];
  293.  
  294. cout << " Validate Data " << endl;
  295. for( int student_no = 0; student_no < No_of_students; student_no++)
  296. {
  297.  
  298. for (int subject_no = 0; subject_no < No_of_subjects ; subject_no++)
  299. {
  300. if (student[student_no].validate_exam_mark(lc_results[student_no][subject_no]) == false)
  301. {
  302. cout << lc_results[student_no][subject_no]<< "is not a valid mark ??????" << endl;
  303. }
  304. else
  305. {
  306. /// cout << lc_results[student_no][subject_no]<< "is a valid exam result " << endl;
  307. }
  308.  
  309. }
  310. }
  311.  
  312. cout << "Report 1 Data " << endl;
  313. cout << endl;
  314. cout << "Names " ;
  315. for (int i=0;i<6;i++)
  316. {
  317. cout << setw(10) << sub_name[i]; /// Column headings
  318. }
  319. cout << endl;
  320.  
  321. for ( int student_no = 0 ; student_no < No_of_students ; student_no++ );
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement