![]() |
CS301P ASSIGNMENT NO. 1 FALL 2022 |
KINDLY, DON’T COPY PASTE
CS301P ASSIGNMENT NO. 1 FALL 2022 || 100% RIGHT SOLUTION || DATA STRUCTURES (PRACTICAL) || BY VuTech
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
Ø The assignment is submitted after due date.
Ø The submitted code does NOT compile.
Ø The submitted assignment file is other than .CPP format.
Ø The submitted assignment file does not open or corrupted.
Ø The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
For clarity and simplicity, you are required to Upload/Submit only one .CPP file.
Ø Don’t wait for grace day. Grace Day is given only if there is problem with LMS on due date. Submit your solution within due date.
Ø Note that no assignment will be accepted through email if there is any problem on grace day.
Note: Use only Dev C++ IDE.
Objective
The objective of this assignment is to make you familiar with Linked List data structures and programming techniques related to them.
For any query about the assignment, contact at cs301p@vu.edu.pk
GOOD LUCK
Requirements:
- You have to use only Linked List data structure for this assignment. Your marks will be deducted if any other data structure is used
- Your program should perform the below mentioned operations on the output console:
§ Linked List will be used to store the information of all candidates.
§ The program will accept “Candidate Name” ,“subject test marks”, “interview marks” as input parameters.
§ The candidate will only be considered eligible for post of lecturer if he/she secures more than 70 marks in the subject test and more than 80 marks in the interview. Otherwise he/she will be considered ‘ineligible’
§ The program should display the record of eligible and ineligible candidates separately.
Solution Guidelines:
1) Understand and practice the following topics before developing this assignment::
R Nodes
R List
R Linked List
RLinked List Methods
2) To save candidate information, use the Linked List data structure. Each candidate will be represented by a node that contains the following information: candidate name,subject test score,interview marks,and status (eligible/ineligible).
3) Your solution should use these classes:
a. Candidate (Node) Class: To save information of each candidate
b. List Class: To save all candidates in linked list
Sample Output
See the attached video file (output.mp4) to see the sample output.
Labs Covered:
This assignment covers Lab # 1- 3
Deadline:
Your assignment must be uploaded / submitted on / before, Monday 5th December 2022
SOLUTION:
#include<iostream>
using namespace std;
class Applicant{
private:
int Id, testScore, interviewmarks;
string name, status;
Applicant *nextCandidate;
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){
nextCandidate=ptr;
}
Applicant* getNextApplicant(){
return nextCandidate;
}
};
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
newNode->setStatus("Ineligible");
}
else
{
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++;
}
cout<<"Total number of Applicant: "<<count<<endl;
}
}
bool next(Applicant *ptr){
if(ptr==NULL){
return true;
}
else{
return false;
}
}
void updateApplicant(){
if(next(head)==true){
cout<<"No Applicant Added Yet"<<endl;
}
else{
int t_id,found=0,i;
cout<<"Enter Applicant ID:";
cin>>t_id;
Applicant *ptr=head;
while(next(ptr)==false){
if(t_id==ptr->getId()){
cout<<"Enter the Name of Applicant:";
ptr->setName();
cout<<"Enter the Test Score of Applicant: ";
ptr->setTestScore();
if(ptr->getTestScore()>=80){
cout<<"Enter the Interview Marks os Applicant: ";
cin>>i;
cout<<endl;
ptr->setInterviewmarks(i);
if(ptr->getInterviewmarks()>50)
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;
}
}
}
friend void displayApplicant(Linked_List *obj, int choice){
if(obj->next(obj->head)==true){
cout<<"No Applicant Added Yet"<<endl;
}
else{
if(choice==3)
{
Applicant *ptr=obj->head;
while(obj->next(ptr)==false){
if(ptr->getstatus()=="Eligible"){
cout<<"======================================="<<endl<<endl;
cout<<"Applicant ID:"<<ptr->getId()<<endl;
cout<<"Applicant Name:"<<ptr->getName()<<endl;
cout<<"Applicant TestScore:"<<ptr->getTestScore()<<endl;
cout<<"Applicant Interview MArks:"<<ptr->getInterviewmarks()<<endl;
cout<<"Applicant Status: "<<ptr->getstatus()<<endl;
}
ptr=ptr->getNextApplicant();
}
}
else{
Applicant *ptr= obj->head;
while(obj->next(ptr)==false){
if(ptr->getstatus()=="Ineligible"){
cout<<"======================================="<<endl<<endl;
cout<<"Applicant ID: "<<ptr->getId()<<endl;
cout<<"Applicant Name: "<<ptr->getName()<<endl;
cout<<"Applicant TestScore: "<<ptr->getTestScore()<<endl;
cout<<"Applicant Interview MArks: "<<ptr->getInterviewmarks()<<endl;
cout<<"Applicant Status: "<<ptr->getstatus()<<endl;
}
ptr=ptr->getNextApplicant();
}
}
}
}
};
main(){
Linked_List L;
int choice,number;
do{
cout<<endl<<"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<<endl;
cin>>choice;
switch(choice){
case 1:
cout<<"Enter the number of Applicants you want to add or see result: ";
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;
default:
cout<<"Press other number to close the program"<<endl<<endl;
}
}
while(choice>=1 && choice<=5);
return 0;
}
KINDLY, DON’T COPY PASTE
SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com