CS301 Assignment No 1 Solution Spring 2018 | Virtual Study Solutions

Adsetra Ads

 

CS301 Assignment No 1 Spring 2018

Dear Students, Here you can read or Download CS301 - Data Structures Assignment No 1 Solution and Discussion of Semester Spring 2018. Assignment Due Date is 10 MAY, 2018. Total Marks are 20. This assignment covers lesson no. 1-8. We are here to facilitate your learning and we do not appreciate the idea of copying or replicating solutions. CS301 Assignment Solution File has been added. Previously we shared CS301 Current and Past Mid Term Papers Fall 2017.


CS301 Assignment No 1 Solution Spring 2018
CS301 Assignment No 1 Solution Spring 2018

CS301 Assignment Instructions

Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (marks) if:

  • The assignment is submitted after due date.
  • The submitted code does NOT compile.
  • The submitted assignment file is not in .CPP format.
  • The submitted assignment file does not open or is corrupted.
  • The assignment is copied (from other student or ditto copy from handouts or internet).

CS301 Assignment Uploading instructions

For clarity and simplicity, You are required to Upload/Submit only .cpp file which will contain solution of question.
  • Do not 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 in LMS on grace day.
Please Note: Use only dev-C++ IDE.

CS301 Assignment Objective

The objective of this assignment is To make you familiar with link list data structure and programming techniques to implement and understand working of this data structure.

CS301 Assignment Question No 1:

Write a C++ program to create and save students information into linked list.


CS301 Assignment No 1 Question Spring 2018
CS301 Assignment No 1 Question Spring 2018

Your program should fulfill following requirements.

(1) Your program will save the information of student into a student object.

(2) Then create list of students which will save into a liked list. The structure of Student object and Students list is showing above in the diagram.

(3) After making the list of students, give 3 options to user to perform some search operations from the list as given below.

  • Show all students from the list who are enrolled in the course (code entered by user). 
  • Show all students from the list who got greater than or equal CGPA mentioned by user. Suppose user entered 3.4 then all students who got 3.4 or more CGPA should show on the screen. 
  • Show all students from the list who got greater than or equal to Marks mentioned by user. Suppose user entered 65 then all students who got 65 or more Marks should show on the screen. 
(4) User should be able to repeat different type of searches without closing the program. You can see this functionality in Sample Output Demo video attached with assignment file. For demonstration of required solution, watch attached “Sample Demo” video file.


Assignment No 1 Solution Spring 2018

You can see the Sample Preview of Assignment No 1 Solution provided by (Virtual Study Solutions) below. Click on Download Button to Download Solution File in Your PC. Please Share it with your friends. You can also like our Facebook Page or Subscribe Us below for Updates.

Assignment Solution Sample Preview

Solution File Sample Code Preview has been added Soon with Solution File.

#include<iostream>
using namespace std;
struct node{
 string name, course;
 int marks;
 float cgpa;
 node *next;
};
bool empty(node *head);
char menu();
void addList(node *&head, node *&last);
void showList(node *current);
void find_data(node *find);
void find_data_marks(node *find);

bool empty(node *head){
 if(head == NULL){
   return true;
 }else{
  return false;
 }
}

char menu()
{
 char select;
 cin>>select;
 return select;
}
void addList(node *&head, node *&last){
 string n;
 string co;
 int m;
 float cg;
 cout<<"\nName of student: ";
 cin>>n;
 cout<<"Course_code of student: ";
 cin>>co;
 cout<<"Marks of student:";
 cin>>m;
 cout<<"CGPA of student: ";
 cin>>cg;
 if(empty(head)){
  node *student = new node;
  student->name = n;
  student->course = co;
  student->marks = m;
  student->cgpa = cg;
  student->next = NULL;
  head = student;
  last = student;
 }else{
  node *student = new node;
  student->name = n;
  student->course = co;
  student->marks = m;
  student->cgpa = cg;
  last->next = student;
  last = student;
 }

}
void showList(node *current){
 if(empty(current)){
  cout<<"List is empty \n";
 }else{
  cout<<"List Contains: \n";
  while(current != NULL){
   cout<<"Student name = "<<current->name<<"\n";
   cout<<"Student Course Code = "<<current->course<<"\n";
   cout<<"Student Marks = "<<current->marks<<"\n";
   cout<<"Student CGPA = "<<current->cgpa<<"\n";
   current = current->next;
  }
 }
}
void find_data(node *find){
 float f_cgpa;
 cout<<"Please enter student CGPA: ";
 cin>>f_cgpa;
 while(find !=NULL){
  if(find->cgpa == f_cgpa){
   cout<<"Student name = "<<find->name<<"\n";
   cout<<"Student Course Code = "<<find->course<<"\n";
   cout<<"Student Marks = "<<find->marks<<"\n";
   cout<<"Student CGPA = "<<find->cgpa<<"\n";
  }else{
   cout<<"Data not found!!! \n";
  }
 find = find->next;
 }
}
void find_data_marks(node *find){
 int marks1;
 cout<<"Please enter student Marks: ";
 cin>>marks1;
 while(find !=NULL){
  if(find->marks == marks1){
   cout<<"Student name = "<<find->name<<"\n";
   cout<<"Student Course Code = "<<find->course<<"\n";
   cout<<"Student Marks = "<<find->marks<<"\n";
   cout<<"Student CGPA = "<<find->cgpa<<"\n";
  }else{
   cout<<"Data not found!!! \n";
  }
 find = find->next;
 }
}
int main()
{
 node *head = NULL;
 node *last = NULL;
 char select;
 cout<<"\n\t\t\t\t\t\tPlease enter numbers from 1 to 5: \n";
 cout<<"1. Add data in list: \n";
 cout<<"2. Show data from the list: \n";
 cout<<"3. find data of Student by CGPA: \n";
 cout<<"4. find data of Student by Marks: \n";
 cout<<"5. Exit the Program: \n";
 do{
  select = menu();
  switch(select)
  {
   case '1':
    system("cls");
    cout<<"\n\t\t\t\t\t\tPlease enter numbers from 1 to 5: \n";
    cout<<"1. Add data in list: \n";
    cout<<"2. Show data from the list: \n";
    cout<<"3. find data of Student by CGPA: \n";
    cout<<"4. find data of Student by Marks: \n";
    cout<<"5. Exit the Program: \n";
    cout<<"\t\t\t\t\t\t:::::STUDENT ENTRY::::: \n";
    cout<<"Please enter student data";
    addList(head, last);
    break; 
   case '2':
    system("cls");
    cout<<"\n\t\t\t\t\t\tPlease enter numbers from 1 to 5: \n";
    cout<<"1. Add data in list: \n";
    cout<<"2. Show data from the list: \n";
    cout<<"3. find data of Student by CGPA: \n";
    cout<<"4. find data of Student by Marks: \n";
    cout<<"5. Exit the Program: \n";
    cout<<"\t\t\t\t\t\t:::::SHOW STUDENT LIST::::: \n";
    showList(head);
    break;
   case '3':
    system("cls");
    cout<<"\n\t\t\t\t\t\tPlease enter numbers from 1 to 5: \n";
    cout<<"1. Add data in list: \n";
    cout<<"2. Show data from the list: \n";
    cout<<"3. find data of Student by CGPA: \n";
    cout<<"4. find data of Student by Marks: \n";
    cout<<"5. Exit the Program: \n";
    cout<<"\t\t\t\t\t\t:::::find STUDENT LIST by CGPA::::: \n";
    find_data(head);
    break;
   case '4':
    system("cls");
    cout<<"\n\t\t\t\t\t\tPlease enter numbers from 1 to 5: \n";
    cout<<"1. Add data in list: \n";
    cout<<"2. Show data from the list: \n";
    cout<<"3. find data of Student by CGPA: \n";
    cout<<"4. find data of Student by Marks: \n";
    cout<<"5. Exit the Program: \n";
    cout<<"\t\t\t\t\t\t:::::find STUDENT LIST by MARKS::::: \n";
    find_data_marks(head);
    break;
   default:
    cout<<"System exit \n";
    break;
  }
 }while(select!='5');

 return 0;
}


You can test the Code by Following URL : http://cpp.sh/3t5pp

Assignment Solution Download Link

Download  [ Solution File Upload Status :   ]


Post a Comment

  1. This is correct one



    #include
    using namespace std;
    struct node{
    string name, course;
    int marks;
    float cgpa;
    node *next;
    };
    bool empty(node *head);
    char menu();
    void addList(node *&head, node *&last);
    void showList(node *current);
    void find_data(node *find);
    void find_data_marks(node *find);

    bool empty(node *head){
    if(head == NULL){
    return true;
    }else{
    return false;
    }
    }

    char menu()
    {
    int select;
    cin>>select;
    return select;
    }

    void search_by_course(node *find){
    string courseCode;
    string nextSearch;
    cout<<"Please enter course code: ";
    cin>>courseCode;
    int whileCount =1;
    while(find !=NULL){
    if(find->course == courseCode){
    cout<<"Student "<name<<" "<course<<" "<marks<<" "<cgpa<<"\n";
    }
    else{}
    find = find->next;
    whileCount++;
    }
    }
    void find_data(node *find){
    int whileCount =1;
    float f_cgpa;
    cout<<"Please enter student CGPA: ";
    cin>>f_cgpa;
    while(find !=NULL){
    if(find->cgpa >= f_cgpa){
    cout<<"Student "<name<<" "<course<<" "<marks<<" "<cgpa<<"\n";
    }
    else{}
    find = find->next;
    whileCount++;
    }
    }
    void find_data_marks(node *find){
    int marks1;
    int whileCount =1;
    cout<<"Please enter student Marks: ";
    cin>>marks1;
    while(find !=NULL){
    if(find->marks >= marks1){
    cout<<"Student "<name<<" "<course<<" "<marks<<" "<cgpa<<"\n";
    }
    else{}
    find = find->next;
    whileCount++;
    }
    }
    int main()
    {
    node *head = NULL;
    node *last = NULL;
    char select;
    cout<<"How many number of students you want to enter into list?: ";
    select = menu();
    int numCount = 0;
    for (int x=1; x<=select; x++)
    {
    string n;
    string co;
    int m;
    float cg;
    cout<<"\nName of student: ";
    cin>>n;
    cout<<"Course_code of student: ";
    cin>>co;
    cout<<"Marks of student:";
    cin>>m;
    cout<<"CGPA of student: ";
    cin>>cg;
    cout<<"Student's information saved successfully. \n\n";

    node *student = new node;
    student->name = n;
    student->course = co;
    student->marks = m;
    student->cgpa = cg;
    student->next = head;
    head = student;
    last = student;
    numCount++;

    }
    cout<<"\nList Size = "<<numCount<<"\n\n";

    cout<<"What type of serach you want to perform? Enter only 1,2 and 3 for choice. \n";
    cout<<"1. Search All Students By Course Code: \n";
    cout<<"2. Search all students by marks greater than equal to: \n";
    cout<<"3. Search all students by cgpa greater than equal to: \n";
    cout<<"Choice:";
    do{
    select = menu();
    switch(select)
    {
    case 1:
    system("cls");
    search_by_course(head);
    break;
    case 2:
    system("cls");
    find_data_marks(head);
    break;
    case 3:
    system("cls");
    find_data(head);
    break;
    default:
    cout<<"Press any key to continue.. \n";
    break;
    }
    }while(select!='5');
    return 0;
    }

    ReplyDelete
  2. Gud man I'll give + rating after checking it....

    ReplyDelete
  3. Cs 301 assignmnt no 1 solution plz urgent .....2019

    ReplyDelete

 

Top