Advertisement
BSIT_21

Linked Listing [GELACIO]/[PULAN]

Jul 31st, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.55 KB | None | 0 0
  1. #include<conio.h>
  2. #include<iostream>
  3. #include<fstream>
  4. #include<Windows.h>
  5. #include<dos.h>
  6. #include<cctype>
  7. #include<sstream>
  8. #include<string>
  9. using namespace std;
  10. bool check = true;
  11. struct node
  12. {
  13.  string name;
  14.  int grade;
  15.  node *next;
  16. }*head,*lastptr;
  17.  
  18.  
  19. void display(struct node* head, char Cchoice,int Igrade)
  20.     {
  21.           struct node *temp = head;
  22.           cout <<"\n\nList elements are - \n";
  23.           while(temp != NULL)
  24.           {
  25.             switch(toupper(Cchoice))
  26.             {
  27.                 case 'A':
  28.                 if (temp->grade==Igrade)
  29.                 {
  30.                 cout << "Name: " << temp->name<<endl;
  31.                 cout << "Grade: " << temp->grade<<endl;
  32.                 } break;
  33.                 case 'B':
  34.                 if (temp->grade>Igrade)
  35.                 {
  36.                 cout << "Name: " << temp->name<<endl;
  37.                 cout << "Grade: " << temp->grade<<endl;
  38.                 }break;
  39.                 case 'C':
  40.                 if (temp->grade<Igrade)
  41.                 {
  42.                 cout << "Name: " << temp->name<<endl;
  43.                 cout << "Grade: " << temp->grade<<endl;
  44.                 }break;
  45.                 default:
  46.                 cout << "Name: " << temp->name<<endl;
  47.                 cout << "Grade: " << temp->grade<<endl;
  48.  
  49.             }
  50.             temp = temp->next;
  51.  
  52.             }
  53.     }
  54.  
  55. void add()
  56. {
  57.  node *p;
  58.  p=new node;
  59.  cout<<"Enter name of student: "<<endl;
  60.  cin>> p->name;
  61.  
  62.  cout<<"Enter Grade: "<<endl;
  63.  cin>>p->grade;
  64.  
  65.  p->next=NULL;
  66.  
  67.  if(check)
  68.  {
  69.   head = p;
  70.   lastptr = p;
  71.   check = false;
  72.  }
  73.  else
  74.  {
  75.   lastptr->next=p;
  76.   lastptr=p;
  77.  }
  78.  cout<<endl<<"Recorded"<<endl;
  79.  getch();
  80. }
  81.  
  82.  
  83.  
  84. int main()
  85. {
  86.  char x;
  87.  cout<<"\t\t ******************************* \t\t\t"<<endl;
  88.  cout<<"\t\t ***STUDENT MANAGEMENT SYSTEM*** \t\t\t"<<endl;
  89.  cout<<"\t\t ******************************* \t\t\t"<<endl<<endl;
  90.  
  91.  getch();
  92.  char choice = 'X', Cchoice = 'X', Nchoice = 'X';
  93.  int i=0, Igrade=0;
  94.  while (toupper(choice)!='N')
  95.     {
  96.         add(); i++;
  97.         cout<<"More Entry [Y] / [N]: "; cin>>choice;
  98.     }
  99.  
  100.     while (toupper(Nchoice)!='N')
  101.     {
  102.         cout << "Criteria for displaying the list: "<<endl;
  103.         cout << "A. Grade =\nB. Grade >\nC. Grade < \n D. All\n";
  104.         cout << "Enter Choice (A-D): "; cin>>Cchoice;
  105.         if(toupper(Cchoice)!='D')
  106.         {
  107.         cout << "Grade: ";cin>>Igrade;
  108.         }
  109.         display(head, Cchoice, Igrade);
  110.         cout<<"More Entry [Y] / [N]: "; cin>>Nchoice;
  111.     }
  112.     system("pause");
  113.     return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement