Monday 20 June 2022

Download CS301 Solved Assignment no 1 solution 2022

 CS301 Assignment 1 Solution 2022 - Download CS301 Solved Assignment no 1 solution 2022 In Word Format Solution:




#include<iostream> using namespace std; class Applicant{
private:
int Id, testScore, interviewmarks; string name, status;
Applicant *nextApplicant; public:
void setId(){
cin>>Id;

}
int getId(){
return Id;

}
void setName(){
 


cin>>name;
}

string getName(){ return name;
}
void setTestScore(){ cin>>testScore;
}
int getTestScore(){ return testScore;
}
void setInterviewmarks(int i){ interviewmarks=i;
}
int getInterviewmarks(){ return interviewmarks;
}
void setStatus(string s){
 


status=s;
}

string getstatus(){ return status;
}
void setNextApplicant( Applicant *ptr){ nextApplicant=ptr;
}
Applicant* getNextApplicant(){ return nextApplicant;
}
};

class Linked_List{ Applicant* head; Applicant* current; public:
Linked_List(){
head=NULL;
 


current=NULL;
}

void addApplicant(){ int i;
Applicant *newNode= new Applicant; cout<<"Enter the ID of Applicant:"<<endl; newNode->setId();
cout<<"Enter the Name of Applicant:"<<endl; newNode->setName();
cout<<"Enter the Test Score of Applicant:"<<endl;
newNode->setTestScore(); if(newNode->getTestScore()>=80){
cout<<"Enter the Interview Marks of
 
Applicant: "<<endl;
 


cin>>i;
newNode->setInterviewmarks(i); if(newNode->getInterviewmarks()>50)
newNode->setStatus("Eligible");
 


 



}
else
{
 
else
newNode->setStatus("Ineligible");
 

newNode->setInterviewmarks(0);
newNode->setStatus("Ineligible"); cout<<"Applicant is not eligible for Job
Interview"<<endl;
}
newNode->setNextApplicant(NULL); if(head==NULL){
head=newNode; current=newNode;
 
}
else{




}
 



current->setNextApplicant(newNode); current=newNode;
 


}
void getInformation(){


if(next(head)==true){
cout<<"No Applicant added yet"<<endl;

 
}
else{
 



int count=0; Applicant *ptr=head;
while(next(ptr)==false){
ptr=ptr->getNextApplicant(); count++;
 



"<<count;


}
 
}
cout<<"Total number of Applicant:


}
 

bool next(Applicant *ptr){ if(ptr==NULL){
 


 

}
else{


}
}
 
return true;




return false;
 

void updateApplicant(){ if(next(head)==true){
cout<<"No Applicant Added Yet"<<endl;

 
}
else{











Applicant:"<<endl;
 



int t_id,found=0,i;
cout<<"Enter Applicant ID:"<<endl; cin>>t_id;
Applicant *ptr=head; while(next(ptr)==false){
if(t_id==ptr->getId()){ cout<<"Enter the Name of
 


 



Applicant: "<<endl;





Marks os Applicant: "<<endl;





>getInterviewmarks()>50)
 
ptr->setName();
cout<<"Enter the Test Score of


ptr->setTestScore();
if(ptr->getTestScore()>=80){ cout<<"Enter the Interview

cin>>i;
ptr->setInterviewmarks(i); if(ptr-

ptr->setStatus("Eligible"); else
ptr->setStatus("Ineligible");
 

 
}
else{
 



ptr->setInterviewmarks(0); ptr->setStatus("Ineligible");
 


cout<<"Applicant is not
Applicable for Job"<<endl;
}

cout<<"Record Updated"<<endl; found++;
}

ptr=ptr->getNextApplicant();
}

if(found==0){
cout<<"Applicant ID not found"<<endl;

}
}
}

 

choice){
 
friend void displayApplicant(Linked_List *obj, int


if(obj->next(obj->head)==true){
cout<<"No Applicant Added Yet"<<endl;
 

}
else{
 


if(choice==3)
{

 




>getstatus()=="Eligible"){ ID:"<<ptr->getId(); Name:"<<ptr->getName();
 
Applicant *ptr=obj->head; while(obj->next(ptr)==false){
if(ptr-


cout<<"Applicant cout<<"Applicant
cout<<"Applicant
 
TestScore:"<<ptr->getTestScore();
cout<<"Applicant
Interview MArks:"<<ptr->getInterviewmarks();
cout<<"Applicant
 
Status: "<<ptr->getstatus();




}
}
 


}
ptr=ptr->getNextApplicant();
 


 
else{





>getstatus()=="Ineligible"){ ID:"<<ptr->getId(); Name:"<<ptr->getName();
 

Applicant *ptr= obj->head; while(obj->next(ptr)==false){
if(ptr-


cout<<"Applicant cout<<"Applicant
cout<<"Applicant
 
TestScore:"<<ptr->getTestScore();
cout<<"Applicant
Interview MArks:"<<ptr->getInterviewmarks();
cout<<"Applicant
 
Status: "<<ptr->getstatus();




}
}
 


}
ptr=ptr->getNextApplicant();
 

}
 


}
};
main(){

Linked_List L;
int choice,number; do{
cout<<"Enter your Choice: "<<endl; cout<<"1. To add Applicant data"<<endl; cout<<"2.Total number of Applicants"<<endl;
cout<<"3.Display data of Eligible Applicants"<<endl; cout<<"4.Display data of Ineligible Applicants"<<endl; cout<<"5.Update Applicant Data"<<endl;
cout<<"Press other number to close the program"<<endl;
cin>>choice; switch(choice){
case 1:
cout<<"Enter the number of Applicants you want to add or see result"<<endl;
 


cin>>number;
for(int i=1;i<=number;i++){ L.addApplicant();
}
break; case 2:
L.getInformation(); break;
case 3:
displayApplicant(&L,choice); break;
case 4:
displayApplicant(&L,choice); break;
case 5:
L.updateApplicant(); break;
}
 


}
while(choice>=1 && choice<=5); return 0;
}

No comments:

Post a Comment