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
  CS301 Assignment 3 Solution Fall 2020 Ayra Suleman 0 1,342 01-25-2020, 11:33 PM
Last Post: Ayra Suleman
  CS301 3rd Assignment solution RashidRoger 0 1,314 01-20-2020, 10:21 AM
Last Post: RashidRoger
  CS301 GDB Solution Spring 2019 Ayra Suleman 0 2,127 08-01-2019, 10:24 PM
Last Post: Ayra Suleman
  CS301 Assignment 3 Solution Spring 2019 Ayra Suleman 0 2,617 07-26-2019, 06:59 PM
Last Post: Ayra Suleman
  CS311 Assignment 2 Solution Spring 2019 Mishi Khan 0 762 06-01-2019, 01:11 AM
Last Post: Mishi Khan
  CS301 Assignment 2 Solution Spring 2019 Mishi Khan 0 756 05-28-2019, 01:57 AM
Last Post: Mishi Khan
  cs301 Assignment 2 solution Muhammad Yaseen 0 482 05-24-2019, 04:03 PM
Last Post: Muhammad Yaseen
  CS301 Assignment Solution Spring 2019 Mishi Khan 0 587 05-11-2019, 09:36 PM
Last Post: Mishi Khan
  cs301 Assignment Muhammad Yaseen 0 436 05-11-2019, 04:45 PM
Last Post: Muhammad Yaseen
  CS301 GDB Solution Mishi Khan 0 966 02-08-2019, 01:42 AM
Last Post: Mishi Khan



Users browsing this thread:
1 Guest(s)