CS301 Data Structures Assignment 1 Solution Fall 2014

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.
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.
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).

Solution:

#include <conio.h>
#include <iostream>
using namespace std;
int n_prime(int n_last);

int main(int argc, char *argv[])
{
int your_num;
cout”Enter No= “;
cin>>your_num;
cout n_prime(your_num);
system(“PAUSE”);
return EXIT_SUCCESS;
}

int n_prime(int n_last){
int count,x;
count=0;
for(x=2;x<=n_last/2;x++){
if(n_last%x==0){
count++;
break;
}
}
if(count==0){
cout”Prime”endl;
}else{
cout”Composite”endl;
}
}
{

public:

Stack() { size = 10; current = -1;} //constructor

int pop(){ return A[current–];} // The pop function

void push(int x){A[++current] = x;} // The push function

int top(){ return A[current];} // The top function

int isEmpty(){return ( current == -1 );} // Will return true when stack is empty

int isFull(){ return ( current == size-1);} // Will return true when stack is full
{

int x = head->get();

Node * p = head;

head = head->getNext();

delete p;

return x;

}
void push(int x)

{

Node * newNode = new Node();

newNode->set(x);

newNode->setNext(head);

head = newNode;

}

DOWNLOAD SOLUTION HERE
loading...