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
Thumbs Up required CS301 solution fahadmukhtar 1 89 05-28-2018, 05:37 PM
Last Post: fahadmukhtar
  cs 301 assignment 2 solution needed rabia nawaz 0 98 05-26-2018, 10:18 PM
Last Post: rabia nawaz
  Required CS301 - Data Structures assignment solution please Javed Latif 0 175 05-08-2018, 12:47 PM
Last Post: Javed Latif
  CS301 Assignment 3 Solution Pakistani 2 2,436 07-09-2017, 07:13 PM
Last Post: Admin
  CS301 Assignment 2 Solution - Spring 2017 Admin 0 1,784 05-17-2017, 08:54 PM
Last Post: Admin
  CS301 Assignment 3 Solution Admin 8 3,105 01-21-2017, 02:25 PM
Last Post: Admin
  CS301 GDB solution Rubaisha(Moody Girl) 0 1,172 08-09-2016, 09:38 AM
Last Post: Rubaisha(Moody Girl)
  CS301 assignment1 text solution Nadeem Rana vu 1 1,143 05-07-2016, 06:00 PM
Last Post: Rubaisha(Moody Girl)
  CS301 Assignment 1 Complete solution Rubaisha(Moody Girl) 0 2,469 05-05-2016, 06:13 PM
Last Post: Rubaisha(Moody Girl)



Users browsing this thread:
2 Guest(s)