Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <stdlib.h>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- class validation
- {
- public:
- bool test_PAC(int PAC_no1, int PAC_no2, int PAC_no3, int Input_PAC1, int Input_PAC2, int Input_PAC3);
- bool validate_exam_mark(float mark);
- bool validate_user_id(int user_id);
- bool validate_PAC(int PAC);
- private:
- int dm_PAC1;
- int dm_PAC2;
- int dm_PAC3;
- int dm_Input_PAC1;
- int dm_Input_PAC2;
- int dm_Input_PAC3;
- int dm_user_id;
- float dm_mark;
- };
- bool validation::validate_exam_mark(float mark)
- {
- dm_mark = mark;
- if(dm_mark <1 || dm_mark >100)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- class results: public validation
- {
- public:
- void display_headings();
- string get_LC_marks(float p_mark);
- int get_LC_points( string p_grade);
- private:
- string dm_grade;
- int dm_cao;
- float dm_mark;
- };
- string results::get_LC_marks(float p_mark)
- {
- dm_mark = p_mark;
- if ( dm_mark >= 90 && dm_mark <= 100)
- {
- dm_grade = "H1";
- }
- return "H1";
- if ( dm_mark >=80 && dm_mark <= 90)
- {
- dm_grade = "H2";
- }
- return "H2";
- if ( dm_mark >=70 && dm_mark <= 80)
- {
- dm_grade = "H3";
- }
- return "H3";
- if ( dm_mark >=60 && dm_mark <= 70)
- {
- dm_grade = "H4";
- }
- return "H4";
- if ( dm_mark >=50 && dm_mark <= 60)
- {
- dm_grade = "H5";
- }
- return "H5";
- if ( dm_mark >=40 && dm_mark <= 50)
- {
- dm_grade = "H6";
- }
- return "H6";
- if ( dm_mark >=30 && dm_mark <= 40)
- {
- dm_grade = "H7";
- }
- return "H7";
- if ( dm_mark > 30 )
- {
- dm_grade = "H8";
- }
- return "H8";
- };
- int results::get_LC_points(string p_grade)
- {
- dm_grade = p_grade;
- if(dm_grade == "H1")
- {
- dm_cao = 100;
- }
- return 100;
- if(dm_grade == "H2")
- {
- dm_cao = 88;
- }
- return 88;
- if(dm_grade == "H3")
- {
- dm_cao = 77;
- }
- return 77;
- if (dm_grade == "H4")
- {
- dm_cao = 66;
- }
- return 66;
- if (dm_grade == "H5")
- {
- dm_cao = 56;
- }
- return 56;
- if (dm_grade == "H6")
- {
- dm_cao = 46;
- }
- return 46;
- if (dm_grade == "H7")
- {
- dm_cao = 37;
- }
- return 37;
- if (dm_grade == "H8")
- {
- dm_cao = 0;
- }
- return 0;
- }
- bool validation::validate_user_id(int user_id)
- {
- dm_user_id = user_id;
- dm_user_id = 12345678;
- if(dm_user_id == 0 )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- 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
- {
- dm_PAC1 = PAC_no1;
- dm_Input_PAC1 = Input_PAC1;
- if ((dm_PAC1 == 1 && dm_Input_PAC1 != 9) || (dm_PAC1 == 2 && dm_Input_PAC1 != 9 )
- || (dm_PAC1 == 3 && dm_Input_PAC1 != 8 ) || (dm_PAC1 == 4 && dm_Input_PAC1 != 8 )
- || (dm_PAC1 == 5 && dm_Input_PAC1 != 1 ) )
- {
- return false;
- }
- else
- {
- return true;
- }
- dm_PAC2 = PAC_no2;
- dm_Input_PAC2 = Input_PAC2;
- if ((dm_PAC2 == 1 && dm_Input_PAC2 != 9) || (dm_PAC2 == 2 && dm_Input_PAC2 != 9 )
- || (dm_PAC2 == 3 && dm_Input_PAC2 != 8 ) || (dm_PAC2 == 4 && dm_Input_PAC2 != 8 )
- || (dm_PAC2 == 5 && dm_Input_PAC2 != 1 ) )
- {
- return false;
- }
- else
- {
- return true;
- }
- dm_PAC3 = PAC_no3;
- dm_Input_PAC3 = Input_PAC3;
- if ((dm_PAC3 == 1 && dm_Input_PAC3 != 9) || (dm_PAC3 == 2 && dm_Input_PAC3 != 9 )
- || (dm_PAC3 == 3 && dm_Input_PAC3 != 8 ) || (dm_PAC3 == 4 && dm_Input_PAC3 != 8 )
- || (dm_PAC3 == 5 && dm_Input_PAC3 != 1 ) )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- const int No_of_students = 6;
- const int No_of_subjects = 6;
- int lc_results[No_of_students] [No_of_subjects] =
- {100,85,75,65,55,45,
- 60,80,75,50,60,75,
- 90,90,90,90,90,90,
- 60,68,75,50,60,55,
- 60,73,75,50,50,75,
- 60,75,75,50,50,65};
- string grade_table [6][6];
- int points_table [6][6];
- int row_average, row_total;
- string sub_name[6] = {"English", "Maths", "Physics", "French" ,"History"};
- string student_name[6] = {"T Jones", "G Addams", "E Kenny", "T May", "B Behan", "D Breen" };
- int pac1, pac2 , pac3;
- int user_pac1,user_pac2, user_pac3;
- int user_id1;
- int Yes_Or_No1, Yes_Or_No2;
- int main()
- {
- class validation user1;
- cout << time(0) << endl ; /// no of seconds since 01011970
- start: srand (time (0)); /// use time(0) as seed value
- pac1 = 1+ (rand()%5); /// use rand to generate an integer 1 or 2 or 3 or 4 or 5
- start2:
- pac2 = 1+ (rand()%5);
- if(pac2 == pac1)
- {
- goto start2;
- }
- start3:
- pac3 = 1+ (rand()%5);
- if(pac3 == pac2 || pac3 == pac1)
- {
- goto start3;
- }
- cout << " Enter your User Id :" << endl;
- cin >> user_id1;
- cout << " " << endl;
- cout << " " << endl;
- cout << "Enter PAC " << pac1 << " :" ; /// Prompt user for PAC no ?
- cin >> user_pac1; /// User enters correct PAC
- cout << " " << endl;
- cout << " " << endl;
- cout << "Enter PAC " << pac2 << " :" ; /// Prompt user for PAC no ?
- cin >> user_pac2;
- cout << " " << endl;
- cout << " " << endl;
- cout << "Enter PAC " << pac3 << " :" ; /// Prompt user for PAC no ?
- cin >> user_pac3;
- cout << " " << endl;
- cout << " " << endl;
- Yes_Or_No1 = user1.test_PAC(pac1,pac2,pac3,user_pac1,user_pac2,user_pac3);
- Yes_Or_No2 = user1.validate_user_id(user_id1);
- if(Yes_Or_No1 == 1 && Yes_Or_No2 == 1)
- {
- cout << " " << endl;
- cout << "Valid User !!!" << endl;
- cout << " " << endl;
- }
- else
- {
- cout << " " << endl;
- cout << "Invalid User !!!" << endl;
- cout << " " << endl;
- }
- class results::results student[6];
- cout << " Validate Data " << endl;
- for( int student_no = 0; student_no < No_of_students; student_no++)
- {
- for (int subject_no = 0; subject_no < No_of_subjects ; subject_no++)
- {
- if (student[student_no].validate_exam_mark(lc_results[student_no][subject_no]) == false)
- {
- cout << lc_results[student_no][subject_no]<< "is not a valid mark ??????" << endl;
- }
- else
- {
- /// cout << lc_results[student_no][subject_no]<< "is a valid exam result " << endl;
- }
- }
- }
- cout << "Report 1 Data " << endl;
- cout << endl;
- cout << "Names " ;
- for (int i=0;i<6;i++)
- {
- cout << setw(10) << sub_name[i]; /// Column headings
- }
- cout << endl;
- for ( int student_no = 0 ; student_no < No_of_students ; student_no++ );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement