CS301 Assignment 2 Solution Spring 2018
#1
CS301 Assignment 2
Spring 2018

Code:
#include<iostream>
using namespace std;
struct node{
    string    roll_num, name, Last_deg;
    char gender;
    node *next;
};
void registering(node *&head, node *&last);
void Display_by_m(node *current);
void Display_by_f(node *current);
void Display_total(node *total);

void registering(node *&head, node *&last){
    string r, n, l;
    char g;
    char a;
    do{
        cout<<"Enter Candidate Roll Number: ";
        cin>>r;
        cout<<"Enter Candidate Name: ";
        cin>>n;
        cout<<"Enter Candidate Gender: ";
        cin>>g;
        cout<<"Enter Candidate's Last Degree: ";
        cin>>l;
        if(head==NULL){
            node *student = new node;
            student->roll_num = r;
            student->name = n;
            student->gender = g;
            student->Last_deg = l;
            head = student;
            last = student;
        }else{
            node *student = new node;
            student->roll_num = r;
            student->name = n;
            student->gender = g;
            student->Last_deg = l;
            last->next = student;
            last = student;
        }
        cout<<"\n Do you want to continue y/n: ";
        cin>>a;
    }while(a=='y'||a=='Y');
}
void Display_by_m(node *current){
    while(current != NULL){
        if(current->gender == 'm'){
            cout<<"Total Candidate verified by invigilator M\n";
            cout<<"RollNo: "<<current->roll_num<<endl;
            cout<<"Name: "<<current->name<<endl;
            cout<<"Gender: "<<current->gender<<endl;
            cout<<"Last Degree: "<<current->Last_deg<<endl;
        }
        current = current->next;
    }
}
void Display_by_f(node *current){
    while(current != NULL){
        if(current->gender=='f'){
            cout<<"Total Candidate verified by invigilator F\n";
            cout<<"RollNo: "<<current->roll_num<<endl;
            cout<<"Name: "<<current->name<<endl;
            cout<<"Gender: "<<current->gender<<endl;
            cout<<"Last Degree: "<<current->Last_deg<<endl;
        }
        current = current->next;
    }
}
void Display_total(node *total){
   int count = 0;  // Initialize count
   struct node* current = total;  // Initialize current
   while (current != NULL)
   {
       count++;
       current = current->next;
   }
   cout<<"Total Candidates verified by invigilator M and invigilator F: "<<count;
}
int main(){
    int choice;
    char b;
    node *head = NULL;
    node *last = NULL;

    do{
        cout<<"Menu\n\n";
        cout<<"1: Register a new Candidate\n\n";
        cout<<"2: Display List of Candidate verified by invigilater M\n\n";
        cout<<"3: Display List of Candidate verified by invigilater F\n\n";
        cout<<"4: Display Total Number of Candidates served\n\n";
        cout<<"5: Exit\n";
        cout<<"***********************************************************\n\n";
        cout<<"Enter your Choice: ";
        cin>>choice;
        
        switch(choice)
        {
            case 1:
                registering(head, last);
                break;
            case 2:
                Display_by_m(head);
                break;
            case 3:
                Display_by_f(head);
                break;
            case 4:
                Display_total(head);
                break;
            default:
                cout<<"system exit";
            break;
        }
        cout<<"\nDo you want to back Menu y/n: ";
        cin>>b;
    }while(b=='y' || b=='Y');
    return 0;
}

Copy the code in DevC++ and save the file. Press F11 to compile and run, grab the screenshots and include them alongside the code in word file to submit your final solution. 

Good luck!


PS. DO NOT COPY PASTE CODE. MAKE CHANGES TO GET GOOD MARKS. 
#2
this is wrong solution in this solution string is used while according to question we have to used array and also queue
so plz upload correct one time is to short.
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS311 Assignment 2 Solution Spring 2019 Mishi Khan 0 199 06-01-2019, 01:11 AM
Last Post: Mishi Khan
  CS301 Assignment 2 Solution Spring 2019 Mishi Khan 0 270 05-28-2019, 01:57 AM
Last Post: Mishi Khan
  cs301 Assignment 2 solution Muhammad Yaseen 0 111 05-24-2019, 04:03 PM
Last Post: Muhammad Yaseen
  CS301 Assignment Solution Spring 2019 Mishi Khan 0 218 05-11-2019, 09:36 PM
Last Post: Mishi Khan
  cs301 Assignment Muhammad Yaseen 0 107 05-11-2019, 04:45 PM
Last Post: Muhammad Yaseen
  CS301 GDB Solution Mishi Khan 0 619 02-08-2019, 01:42 AM
Last Post: Mishi Khan
  CS301 Assignment 2019 Mishi Khan 0 505 01-30-2019, 01:06 AM
Last Post: Mishi Khan
  CS301 MidTerm Past Papers Mishi Khan 0 570 12-14-2018, 09:52 PM
Last Post: Mishi Khan
  CS301 Assignment 1 Solution Fall 2018 Mishi Khan 1 1,305 12-10-2018, 04:39 PM
Last Post: Pakistani
  need GDB CS301 solution raja kamran 3 2,120 08-10-2018, 10:35 AM
Last Post: Pakistani



Users browsing this thread:
1 Guest(s)