Tuesday 8 May 2018

CS301 Assignment Solution 1 2018 In CCP Format

CS301 Assignment 1 Solution 2018:

Cs301 Assignment 2018 Code:

#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;
}

Cs301 Assignment 1 Solution 2018 Past In Dev C++ And Run

No comments:

Post a Comment