Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Coded BY Arkham Knight ELAKIRI /2014/03/31
- #include <iostream>
- #include <iomanip>
- using namespace std;
- /*
- 1. View all studentdata
- 2. View a student’s data using the ID
- 3. Show the highest and the lowest final marks
- */
- void allStudentData();
- void idStudent();
- void showHighLowMarks();
- void menu();
- int main()
- {
- menu();
- }
- int sR[3][5];
- void menu()
- {
- //|StudentID 0 | TMA1 1| TMA2 2| BCAT 3| Final 4
- //student column names
- sR[0][0] = 0;
- sR[0][1] = 1;
- sR[0][2] = 2;
- sR[0][3] = 3;
- sR[0][4] = 4;
- //student One
- sR[1][0] = 1232;
- sR[1][1] = 10;
- sR[1][2] = 23;
- sR[1][3] = 45;
- sR[1][4] = 56;//final mark
- //student two
- sR[2][0] = 2343;
- sR[2][1] = 45;
- sR[2][2] = 43;
- sR[2][3] = 24;
- sR[2][4] = 78;//final mark
- cout << "---------- Menu -----------" << endl;
- cout << "" << endl;
- cout << "1. View all studentdata" << endl;
- cout << "2. View a student’s data using the ID" << endl;
- cout << "3. Show the highest and the lowest final marks " << endl;
- cout << "" << endl;
- cout << "Type a desired value from the given menu and press the ENTER key to proceed" << endl;
- int givenVal = 0;
- cin >> givenVal;
- cin.ignore();
- switch (givenVal)
- {
- case 1:
- allStudentData();
- break;
- case 2:
- idStudent();
- break;
- case 3:
- showHighLowMarks();
- break;
- default:
- cout << "an Error is occurred" << endl;
- cin.clear();//clear the input buffer
- menu();
- break;
- }
- cin.get();
- }
- void allStudentData()
- {
- cout << " "; for(int i=0;i<40;i++){ cout << "_";} cout << endl;
- cout << "|" << setw(11) << "StudentID 0" << "|" << setw(6) << "TMA1 1" << "|" << setw(6) << "TMA2 2" << "|" << setw(6) << "BCAT 3" << "|" << setw(7) << "Final 4|" << endl;
- cout << "|" << setw(11) << sR[1][0] << "|" << setw(6) << sR[1][1] << "|" << setw(6) << sR[1][2] << "|" << setw(6) << sR[1][3] << "|" << setw(7) << sR[1][4] << "|" << endl;
- cout << "|" << setw(11) << sR[2][0] << "|" << setw(6) << sR[2][1] << "|" << setw(6) << sR[2][2] << "|" << setw(6) << sR[2][3] << "|" << setw(7) << sR[2][4] << "|" << endl;
- cout << " "; for(int i=0;i<40;i++){ cout << "_";} cout << endl;
- }
- void idStudent()
- {
- cout << "Id the of the student to see" << endl;
- int stdID;
- cin >> stdID;
- cin.ignore();
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<5;j++)
- {
- if(sR[i][j] == stdID)
- {
- cout << "Student ID.is :" << sR[i][j] << endl;
- cout << "TMA1.......is :" << sR[i][j+1] << endl;
- cout << "TMA2.......is :" << sR[i][j+1] << endl;
- cout << "BCAT.......is :" << sR[i][j+2] << endl;
- cout << "Final......is :" << sR[i][j+4] << endl;
- break;
- }
- }
- }
- }
- void showHighLowMarks()
- {
- int fM[2];//for receiving final marks
- int k=0;
- for(int i=1;i<3;i++)
- {
- for(int j=0;j<5;j++)
- {
- if(j==4)//final mark value
- {
- fM[k] = sR[i][j];
- k++;
- }
- }
- }
- //sorting
- for(int i=0;i<1;i++)
- {
- int temp = fM[i+1];
- if(temp < fM[i])
- {
- fM[i+1] = fM[i];
- fM[i] = temp;
- }
- }
- cout << "The Highest value is..." << fM[1] << endl;
- cout << "The Lowest value is...." << fM[0] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment