We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

CS301 Assignment No 01 Fall 2020 Solution & Discussion Due Date: 26-11-2020

Problem Statement:
Suppose you are asked to make a Ranking information chart of students in a dynamic list called linked list using C++ language. The data will be stored in this list in order i.e. the highest marks student will be on top position with other information whereas the next highest marks student will be on second top position and so on.
Your program will get the information of a student in the form of input (Student ID, Name, Marks) through console. After filling the required information, the student will be inserted in linked list at right place. The right place of student will be decided on the basis of marks.
Furthermore, you are required to use only classes for this assignment. As we are not covering Struct in this course so using it in assignment solution is not allowed.
Sample Output:
See the gif file attached with this assignment file.

Note:
DO REMEMBER that you must use your VUID as an input in this program.

  Submission detailsFollowing Files Must be submitted in a single zip or rar file.C++ code file (file name should be your VUID)A .gif file which shows only “execution” of your Application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well)First record must be with your own VU-ID in .gif file.  If you do not submit any of the above-mentioned file or use some other VU-ID, you will be awarded Zero Marks. 

Views: 2222

Replies to This Discussion

CS301 Assignment 1 Solution 2020 | CS301 Assignment No 1 Solution Fall 2020

CS301 Assignment 1 Solution 2020, CS301 Assignment No 1 Solution Fall 2020, CS301 Assignment 1 Solution 2020, CS301 Assignment No 1 Solution Fall 2020, CS301, CS301Assignment1, CS301AssignmentSolution, CS301SolvedAssignment, CS301Assignment1Solution2020, CS301Assignment1fall2020, CS301AssignmentSolution, CS301Programming, CS301AssignmentNo1, CS301Assignment1Solution2020, CS301Solution CS301Assignment1Solution2020 CS301SolutionLink CS301Assignment1Solution2020 CS301DownloadLink CS301AssignmentPDF CS301AssignmentCPP CS301Assignment1Solution2020 CS301AssignmentSolutionCPP CS301CPPFile CS301Assignment CS301Assignment1Solution2020 CS301AssignmentDownload CS301Solve CS301Assignment1Solution2020 CS301Assignment1 CS301Assignment1Solution2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020 CS301 Assignment 1 Solution 2020

CS301 Data Structures Assignment 1 Solution & Discussion Fall 2020


Updated Solution:

 

#include<iostream>
using namespace std;

class Node
{
public :
string st_id;
string f_name;
string l_name;
int marks;
Node *nextNode;

Node()
{
st_id="";
f_name="";
l_name="";
marks=0;
}

Node(string id, string f_nm, string l_nm, int mrk)
{
st_id=id;
f_name=f_nm;
l_name=l_nm;
marks=mrk;
}

void setVUID(string id)
{
st_id=id;
}
void setMarks(int m)
{
marks=m;
}
void setFName(string f_n)
{
f_name=f_n;
}
void set_LName(string l_n)
{
l_name=l_n;
}

int getMarks()
{
return marks;
}
string getSTID()
{
return st_id;
}
string getFName()
{
return f_name;
}
string getLName()
{
return l_name;
}
};

class Student_List
{
private :
Node * headNode;
public :
Student_List()
{
headNode = NULL;
}

void add_student(Node **head, Node* newNode)
{
Node* currentNode;
if(*head == NULL || (*head)->marks <= newNode->marks)
{
newNode->nextNode = *head;
*head=newNode;
}
else
{
currentNode = *head;
while(currentNode->nextNode != NULL && currentNode->nextNode->marks > newNode->marks)
{
currentNode=currentNode->nextNode;
}
newNode->nextNode=currentNode->nextNode;
currentNode->nextNode=newNode;
}
}

void new_Node()
{
string id;
string f_nm;
string l_nm;
int mrk;
cout"Enter VU ID : ";
cin>>id;
cout"Enter Marks: ";
cin>>mrk;
cout"Enter First Name : ";
cin>>f_nm;
cout"Enter Last Name : ";
cin>>l_nm;

Node* newNode= new Node(id,f_nm,l_nm,mrk);

newNode->nextNode=NULL;
add_student(&headNode, newNode);
}

void display_Student()
{
Node* node1 = headNode;
if(node1==NULL)
{
cout"No student entered yet "endl;
}
else
{
while(node1!=NULL)
{
cout"\n\nVU ID : "node1->getSTID();
cout"\nMarks: "node1->getMarks();
cout"\nFirst Name : "node1->getFName();
cout"\nLast Name : "node1->getLName()endl;
node1=node1->nextNode;
}
}
}
};


main()
{

Student_List * list = new Student_List();
bool close=1;
int ch=0;
do
{
cout"\n1. To add new student in ranking";
cout"\n2. To display ranking";
cout"\n3. To close";
cout"\n\nEnter your choice (1, 2 or 3) : ";
cin>>ch;

if(ch==1)
{
list->new_Node();
}
else if(ch==2)
{
cout"\nRanking Chart\n";
list->display_Student();
}
if(ch==3)
{
close=0;
cout"\n\n\n\tSearch QueryVU for more solutions\n\n";
}

}while(close);
}

CS301 Assignment No 1 Solution | Data Structure | Virtual Uni | Deadline Nov 26 2020 | Urdu / Hindi

CS301 Assignment No.1 2020
#include <iostream>
using namespace std;
class Books{
private:
int current;
int books;
int size;
int *stack;

public:
Books(int s, int b){
size = s;
stack = new int[size];
books = b;
current = -1;
}
void push(int x){
stack[++current] = x;
}
int pop(){
return stack[current--];
}
int top(){
return stack[current];
}
int isEmpty(){
return (current==-1);
}
int isFull(){
return (current == size-1);
}
};

main(){
int s, b, id;
int s_books = 0;
int h_books = 0;
int o_books = 0;

cout "Set the size of stack: " endl;
cin >> s;

cout "How many books you want to add in stack" endl;
cin >> b;

Books book(s,b);
for(int i = 0; i < b; i++){
if(!book.isFull()){
cout "Enter book identity number that you want to insert into stack" endl;
cin >> id;
book.push(id);

}
}
for(int i = 0; i < b; i++){
if(!book.isEmpty()){
int idd = book.pop();
if(idd%8==0){
s_books++;
}
else if(idd%5==0){
h_books++;
}
else{
o_books++;
}
}
}
if(b > 0){
cout "total software book/books " s_books endl;
cout "total hardware book/books " h_books endl;
cout "total other book/books" o_books endl;
}else{
cout "books not found";
}

}

#CS301 Solution
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
class StudentDetail{
public:
string name;
string lname;
string vuid;
int marks;
};
class Node{
private:
StudentDetail newStd;
Node*next;
public:
StudentDetail get()
{
return newStd;
}
void set(StudentDetail student)
{
this->newStd = student;
}
Node*getNext()
{
return next;
};
void setNext(Node*n )
{
this->next=n;
};
};
class LinkedList{
private:
int size=0;
Node*headPtr;
Node*curPtr;
public:
LinkedList()
{
headPtr = new Node();
headPtr->setNext(NULL);
curPtr = NULL;
}
void add(StudentDetail student)
{
Node*newNode = new Node();
newNode->set(student);
size++;
if(curPtr !=NULL)
{
curPtr = headPtr;
for (int i = 1; i <size; i++)
{
if (((curPtr->getNext())->get().marks)< (student.marks) )
break;
else
curPtr = curPtr->getNext();
}
if((curPtr->getNext())==NULL)
{
newNode->setNext(NULL);
curPtr->setNext(newNode);
}
else
{
newNode->setNext(curPtr->getNext());
curPtr->setNext(newNode);
curPtr = newNode;
}
}
else
{
newNode->setNext(NULL);
headPtr->setNext(newNode);
curPtr = newNode;
}
}
void display()
{
if (curPtr != NULL) {
StudentDetail curstudent;
curPtr = headPtr->getNext();
for (int i = size; i > 0; i--) {
curstudent = curPtr->get();
cout "Stduent VU ID "curstudent.vuid endl "student Marks " curstudent.marksendl "Stdunet First Name" curstudent.nameendl "Stduent Last Name" curstudent.lnameendl;
if (curPtr->getNext() == NULL) break;
curPtr = curPtr->getNext();
}
cout endl;
}
}
};
int main()
{
LinkedList List;
StudentDetail newStudent;
string n,id,l;
int i,m;
do{
cout "1. To Add new student in Ranking"endl "2. To Display Ranking"endl "3. To close"endl "Enter your Choice(1,2,3)"endl ;
cin>>i;
if (i==1)
{
cout "Enter VU ID";
cin>>id;
cout "Enter Marks";
cin>>m;
cout"enter First name";
cin>>n;
cout"enter Last name";
cin>>l;
newStudent.vuid = id;
newStudent.marks = m;
newStudent.name = n;
newStudent.lname = l;
List.add(newStudent);
}
else if(i==2)
{
List.display();
}
else if(i==3)
{exit(3);
}
else
{
cout "wrong selection tray again"endl ;
cin>>i;
}
} while(i!=3);
}

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service