click the link below thanks to get ur answerhttp://adf.ly/uDhtb
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:
o The assignment is submitted after due date.
o The submitted assignment is other than .cpp file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
o The assignment is submitted after due date.
o The submitted assignment is other than .cpp file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
o For clarity and simplicity, you are required to Upload/Submit only .cpp file.
Note: Use only dev-C++ IDE.
o Submit your solution within due date. Don’t wait for grace day. Grace Day is given only if there is any
problem with LMS on due date. Note that no assignment will be accepted through email if there is any
problem on grace day.
problem with LMS on due date. Note that no assignment will be accepted through email if there is any
problem on grace day.
Objective
The objective of this assignment is:
o To give you the practical implementation of linked list data structure.
Problem Statement:
Suppose a company Oraflex organizes interviews for a vacant post. Assume that the interviews of the successful
candidates after short listing has been started and interview marks are being assigned. You being software
developer of the company are assigned a task to prepare candidates’ list that will store candidates’ information
such as their names, test score, interview marks and then display the selected candidate.
candidates after short listing has been started and interview marks are being assigned. You being software
developer of the company are assigned a task to prepare candidates’ list that will store candidates’ information
such as their names, test score, interview marks and then display the selected candidate.
Keeping in view the above scenario, write a program in C++ that will store and display candidates’ names, test
scores, and interview marks. Further, Your program should contain a function to calculate total score of each
candidate. It should also contain a function that will display the total number of candidates appeared. Finally, it
should display the selected candidate.
scores, and interview marks. Further, Your program should contain a function to calculate total score of each
candidate. It should also contain a function that will display the total number of candidates appeared. Finally, it
should display the selected candidate.
Solution Guidelines:
o Use Linked List to implement above scenario.
o Your solution should contain the following two classes:
1. Candidate class (Node class)
2. CandidateList class (LinkedList class)
o Candidate class should contain constructors, setter and getter functions.
o Create a list of candidates and store each candidate’s information in the candidate list.
o Display each candidate’s information as given in simple output.
o Find and Display total number of candidates appeared in interview.
o Find the selected candidate on the basis of highest score obtained.
o Display the selected candidate along with its score (See sample output).
o Your solution should contain the following two classes:
1. Candidate class (Node class)
2. CandidateList class (LinkedList class)
o Candidate class should contain constructors, setter and getter functions.
o Create a list of candidates and store each candidate’s information in the candidate list.
o Display each candidate’s information as given in simple output.
o Find and Display total number of candidates appeared in interview.
o Find the selected candidate on the basis of highest score obtained.
o Display the selected candidate along with its score (See sample output).
Sample Output:
Lectures Covered: This assignment covers Lecture # 1-5
Deadline: Your assignment must be uploaded/submitted at or before. Nov 17 , 2014
Answer :
#include
using namespace std;
class Node{
public:
void set(int object1){
object = object1;
}
int get(){return object;}
Node *getNext(){return nextNode;}
void setNext(Node *next){this->nextNode = next;}
private:
int object;
Node *nextNode;
};
class List{
public:
List();
void add(int addobject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes();
private:
int size;
Node * headNode;
Node *currentNode;
Node * lastCurrentNode;
};
List::List(){// list constructor
headNode= new Node();
headNode-> setNext(NULL);
currentNode = NULL;
lastCurrentNode=NULL;
size=0;
}
void List::add(int addobject){ //method for add new object
Node * newNode= new Node();
newNode->set(addobject);
if(currentNode!=NULL){
newNode->setNext(currentNode->getNext());
currentNode->setNext(newNode);
lastCurrentNode = currentNode;
currentNode = newNode;
}
else{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
}
int List::get(){
if(currentNode!=NULL){
return currentNode->get();
}
}
bool List:: next(){
if(currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if(currentNode==NULL || size==0) return false;
else return true;
}
void traverse(List list){
Node *savedCurrentNode = list.currentNode;
list.currentNode= list.headNode;
for(int i=1; list.next(); i++){
cout"\n Element "i" "list.get();
}
list.currentNode= savedCurrentNode;
}
List addNodes(){
List list;
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(6);
cout"\n list size "list.size;
return list;
}
// main method
main(){
List list = addNodes();
traverse(list);
coutendl;
system("pause");
}
using namespace std;
class Node{
public:
void set(int object1){
object = object1;
}
int get(){return object;}
Node *getNext(){return nextNode;}
void setNext(Node *next){this->nextNode = next;}
private:
int object;
Node *nextNode;
};
class List{
public:
List();
void add(int addobject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes();
private:
int size;
Node * headNode;
Node *currentNode;
Node * lastCurrentNode;
};
List::List(){// list constructor
headNode= new Node();
headNode-> setNext(NULL);
currentNode = NULL;
lastCurrentNode=NULL;
size=0;
}
void List::add(int addobject){ //method for add new object
Node * newNode= new Node();
newNode->set(addobject);
if(currentNode!=NULL){
newNode->setNext(currentNode->getNext());
currentNode->setNext(newNode);
lastCurrentNode = currentNode;
currentNode = newNode;
}
else{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
}
int List::get(){
if(currentNode!=NULL){
return currentNode->get();
}
}
bool List:: next(){
if(currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if(currentNode==NULL || size==0) return false;
else return true;
}
void traverse(List list){
Node *savedCurrentNode = list.currentNode;
list.currentNode= list.headNode;
for(int i=1; list.next(); i++){
cout"\n Element "i" "list.get();
}
list.currentNode= savedCurrentNode;
}
List addNodes(){
List list;
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(6);
cout"\n list size "list.size;
return list;
}
// main method
main(){
List list = addNodes();
traverse(list);
coutendl;
system("pause");
}
got some idea
Idea# 2
Linked list code::
#include<iostream>
using namespace std;
class Node{
public:
void set(int object1){
object = object1;
}
int get(){return object;}
Node *getNext(){return nextNode;}
void setNext(Node *next){this->nextNode = next;}
private:
int object;
Node *nextNode;
};
class List{
public:
List();
void add(int addobject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes();
private:
int size;
Node * headNode;
Node *currentNode;
Node * lastCurrentNode;
};
List::List(){// list constructor
headNode= new Node();
headNode-> setNext(NULL);
currentNode = NULL;
lastCurrentNode=NULL;
size=0;
}
void List::add(int addobject){ //method for add new object
Node * newNode= new Node();
newNode->set(addobject);
if(currentNode!=NULL){
newNode->setNext(currentNode->getNext());
currentNode->setNext(newNode);
lastCurrentNode = currentNode;
currentNode = newNode;
}
else{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
}
int List::get(){
if(currentNode!=NULL){
return currentNode->get();
}
}
bool List:: next(){
if(currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if(currentNode==NULL || size==0) return false;
else return true;
}
void traverse(List list){
Node *savedCurrentNode = list.currentNode;
list.currentNode= list.headNode;
for(int i=1; list.next(); i++){
cout"\n Element "i" "list.get();
}
list.currentNode= savedCurrentNode;
}
List addNodes(){
List list;
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(6);
cout"\n list size "list.size;
return list;
}
// main method
main(){
List list = addNodes();
traverse(list);
coutendl;
system("pause");
}
class Node{
public:
void set(int object1){
object = object1;
}
int get(){return object;}
Node *getNext(){return nextNode;}
void setNext(Node *next){this->nextNode = next;}
private:
int object;
Node *nextNode;
};
class List{
public:
List();
void add(int addobject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes();
private:
int size;
Node * headNode;
Node *currentNode;
Node * lastCurrentNode;
};
List::List(){// list constructor
headNode= new Node();
headNode-> setNext(NULL);
currentNode = NULL;
lastCurrentNode=NULL;
size=0;
}
void List::add(int addobject){ //method for add new object
Node * newNode= new Node();
newNode->set(addobject);
if(currentNode!=NULL){
newNode->setNext(currentNode->getNext());
currentNode->setNext(newNode);
lastCurrentNode = currentNode;
currentNode = newNode;
}
else{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
}
int List::get(){
if(currentNode!=NULL){
return currentNode->get();
}
}
bool List:: next(){
if(currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if(currentNode==NULL || size==0) return false;
else return true;
}
void traverse(List list){
Node *savedCurrentNode = list.currentNode;
list.currentNode= list.headNode;
for(int i=1; list.next(); i++){
cout"\n Element "i" "list.get();
}
list.currentNode= savedCurrentNode;
}
List addNodes(){
List list;
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(6);
cout"\n list size "list.size;
return list;
}
// main method
main(){
List list = addNodes();
traverse(list);
coutendl;
system("pause");
}
students declare 3 variables in Node class instead of object and solve your assignment
click the link below thanks to get ur answerhttp://adf.ly/uDhtb
Reply me on twitter @pak_loverz