CS301 Assignment No 01 Spring 2020 Solution & Discussion
Tags:
Please Discuss here about this assignment.Thanks
Our main purpose here discussion not just Solution
Students having same subject can start discussion here to solve assignment, GDB & Quiz and can clear their concepts until solution is provided.
P.S: Please always try to add the discussion in proper format title like “CS101 Assignment / GDB No 01 Solution & Discussion Due Date: ___________”
Then copy Questions from assignment file and paste in Discussion.
+ http://bit.ly/vucodes (For Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (For Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?)
+ Click Here to Join (Our facebook study Group)
CS301_Assignment_No_01_Solution_Spring_2020
Download the file, Click on the below link
You are required to write a program in C++ to implement Stack data structure and use this data structure to store different types of books based on their identity number. You have to implement Stack data structure using array. A stack is a LIFO structure in which data elements are stored in an order such that last element pushed on the stack will be popped up first. Your program should cover the following scenario. Suppose a student is collecting books and throwing them into stack of books. You need to develop an application that will count different books in the stack. This stack will consist of three types of books i.e. software, hardware and other books. You will identify book with unique numeric identity number. If book identity number will fully dividable by 8, will consider it software book. While the number fully dividable by 5 will consider it hardware book and consider rest of the books as other books. First, the program will ask the user to input size of the stack. Then the programmer will ask the user to input total number of books. Then according to the number of Books, it will ask the user to enter identity number for each book. The book identity number can be any random number between 1 and 99. If book identity number is fully dividable by 8, we will consider it software book. While the number fully dividable by 5 will consider it hardware book and consider rest of the books as other books. Programmer should implement isFull() function of the stack to check if the number of books exceed the size of the stack and isEmpty() function to check if the stack is empty or not. Programmer should also display the message “Books not found” if no books found. Solution Guidelines: 1. First understand the code given in handouts about stack. 2. Get stack size from user to allocate space for stack dynamically. 3. Get identity number of books that user want to enter into the stack. 4. Get value one by one and push into stack. 5. Don’t allow popping if stack is empty and pushing if stack is full. 6. If identity number of book is dividable by 8 and 5 then priority should be given to 8.
#CS301
#CS301Assignment
#DataStructure
#VU
#VUAssignment
#AssignmentSolution
#VUAssignment2020
#CS301Assignment2020
Error ka screenshot share kren.
Dear Students I have Solved and Uploaded the Assignment of CS301. I have also tried to explain it to you.
The biggest issue that comes up when submitting an assignment is copy paste.
To fix this, I have explained in video how we can save copy paste issue by how to do that change in code / assignment.
CS301 Data Structure Assignment No. 1 Solution
You are required to write a program in C++ to implement Stack data structure and use this data structure to store different types of books based on their identity number. You have to implement Stack data structure using array. A stack is a LIFO structure in which data elements are stored in an order such that last element pushed on the stack will be popped up first.
Your program should cover the following scenario.
Suppose a student is collecting books and throwing them into stack of books. You need to develop an application that will count different books in the stack. This stack will consist of three types of books i.e. software, hardware and other books.
You will identify book with unique numeric identity number. If book identity number will fully dividable by 8, will consider it software book. While the number fully dividable by 5 will consider it hardware book and consider rest of the books as other books.
First, the program will ask the user to input size of the stack. Then the programmer will ask the user to input total number of books. Then according to the number of Books, it will ask the user to enter identity number for each book. The book identity number can be any random number between 1 and 99. If book identity number is fully dividable by 8, we will consider it software book. While the number fully dividable by 5 will consider it hardware book and consider rest of the books as other books.
Programmer should implement isFull() function of the stack to check if the number of books exceed the size of the stack and isEmpty() function to check if the stack is empty or not. Programmer should also display the message “Books not found” if no books found.
Solution Guidelines:
1. First understand the code given in handouts about stack.
2. Get stack size from user to allocate space for stack dynamically.
3. Get identity number of books that user want to enter into the stack.
4. Get value one by one and push into stack.
5. Don’t allow popping if stack is empty and pushing if stack is full.
6. If identity number of book is dividable by 8 and 5 then priority should be given to 8.
#CS301
#CS301Assignment
#DataStructure
#VU
#VUAssignment
#AssignmentSolution
#VUAssignment2020
#CS301Assignment2020
CS301 Assignment 1 Complete Solution Spring 2020,CS301 Assignment 1 Complete Solution,CS301 Assignment 1,CS301,CS301 assignment 1 solution,CS301 assignment spring 2020,CS301 assignment solution spring 2020,CS301 assignment, assignment 1 CS301 solution, solution CS301 assignment 1, Cs301 assignment 1 solution 2020,Cs301 assignment solution 2020,Cs301 assignment 1,Cs301 assignment 1 solution spring 2020,Cs301 assignment no 1 solution spring 2020,Cs301 assignment no 1 solution 2020,Cs301 1st assignment solution 2020,Cs301 1st assignment solution,Cs301 1st assignment solution spring 2020,assignment solution spring 2020,CS301 Assignment 1 Complete Solution Spring 2020,CS301 Assignment 1 Complete Solution,CS301 Assignment 1,CS301,CS301 assignment 1 solution,CS301 assignment spring 2020,CS301 assignment solution spring 2020,CS301 assignment,assignment 1 CS301 solution,solution CS301 assignment 1
CS301_Assignment_No_01_Solution_Spring_2020
Download the file, Click on the below link
CS301 Data Structures Assignment 1 Solution & Discussion Spring 2020
CS301 Solution Idea:
Credit: Faizan Nadeem
//student id Bc170403888
// student name Faizan Nadeem
#include<iostream>
using namespace std;
class MYBooks
{
private :
int current;
int books;
int size;
int *stack;
public :
MYBooks(int s, int b)
{size=s;
stack= new int[size];
books=b;
current=-1;
}
void push(int x)
{
// -1 +1=0
stack[++current]=x;
}
int pop()
{
return stack[current--];
}
int top()
{
return stack[current];
}
int isEmpty()
{
return (current==-1);
}
int isFull()
{
//5 4
return (current==size-1);
} }; main()
{ int s, b, id;
int s_books=0, h_books=0, o_books=0;
cout"set the size of stack : ";
cin>>s;
coutendl;
cout"Number of books you want to add in stack : ";
cin>>b;
MYBooks book(s,b);
//b =5
for(int i=0; i<b; i++)
{
if(!book.isFull())
{
coutendl;
cout"Enter book id number that you want to insert into stack :";
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)
{
coutendl;
cout"Total Software Books : "s_books;
coutendl;
cout"Total Hardware Books : "h_books;
coutendl;
cout"Total Other Books : "o_books;
}
else
{
coutendl;
cout"Books not found";
}
}
How to Get This Badge at Your Profile DP
------------------------------------
Management: Admins ::: Moderators
© 2021 Created by + M.Tariq Malik. Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents & non-commercial site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. All Contents on site are for personal & non-commercial use.We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post