CS201 Assignment No 3 Solution Spring 2019 | Virtual Study Solutions

Adsetra Ads

 

CS201 Assignment No 3 Spring 2019

Dear students, here you can read online CS201- Introduction to Programming Assignment No 3 Solution of Spring 2019CS201 Assignment Due Date is 17 JULY, 2019. Total Marks are 20. : This assignment covers lectures 16 -25.We are here to facilitate your learning and we do not appreciate the idea of copying or replicating solutions. .CS201 Assignment No 3 Solution File in .cpp format has been added below Previously we shared CS201 Assignment No 3 Solution Spring 2018.

CS201 Assignment No 3 Solution Fall 2019

File NameDownload Link
CS201 Assignment No 3 Solution Fall 2019 Download



CS201 Assignment No 3 Solution and Discussion Spring 2019
CS201 Assignment No 3 Solution and Discussion Spring 2019

CS201 Assignment Instructions


Please read the following instructions carefully before submitting assignment:

It should be clear that your assignment will not get any credit if:
  • Assignment is submitted after due date.
  • Submitted assignment does not open or file is corrupt.
  • Assignment is copied (From internet/students).

Recommended software for assignment development:



CS201 Assignment Objectives:

Objective of this Assignment is to enable students to understand and practice the concepts of:

  • Variables and operators
  • Loops / Repetition Structures 
  • Switch Statement
  • Functions
  • String Manipulation Functions 
  • Structures 

CS201 Assignment Submission Instructions 

You have to submit only .cpp file on the Assignments interface of CS201 at VULMS. Assignment submitted in any other format will not be accepted and will be graded with zero marks.

CS201 Assignment Problem:

Structures are used to overcome the shortcomings of arrays. Basically arrays are used to store more than one data values of a single datatype.

Ex : int a[100] stores integer datatype values

Whereas if you want to make students result database including student_id (int), student_name (char), marks (float) of more than one student, you cannot use array. Here comes the use of structures. Structures are user defined datatypes which allows you to store data of different types.

Example:

struct Student
{
 int student_id;
 char student_name[50];
 float marks;
}s[10];

CS201 Assignment Statement:


Write a menu based system in C++ for “Library Book Record System” that will take input from user for the following menu. You will create a structure and perform the following operations on the structure.

  • Press 1 To Enter a Book Record.
  • Press 2 To Display all Records of Books Available in Library.
  • Press 3 To Search Books by Author Name.
  • Press 4 To Count Total Books in Library.
  • Press 5 To Exit from the System.
System will take following inputs from user to enter a book record:
  • Book ID
  • Book Title
  • Author of Book
  • Cost of Book

CS201 Assignment Solution Instructions:


  1. Use switch statement for the menu based system.
  2. You can use user defined functions for each of the task mentioned above to manage your code.

  • To Enter a Book Record Add_Book();
  • To Display all Records of Books Available in Library Display_Books();
  • To Search Books by Author Name Book_Author();
  • Count Total Books in Library Count_Books();
Please Note:
You also need to Restrict your system that it do not allow to add more than 5 books and on try of adding books more than limit show message i.e. “No more space in System for another book”.

Use strcmp function to search books by author name in Book_Author(); function.

CS201 Assignment No 3 Solution Spring 2019

You can see the Sample Preview of CS201 Assignment 3 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.

CS201 Assignment No 3 Solution Sample Preview

#include <iostream>
#include <string.h>
 using namespace std;


struct book{
      int book_Id;
      string book_Title;
      string book_Author;
      int book_Cost;
       };
       book libraryp[5];
       int arrayposition=0;
   void addbooks(){
        book bookdetail;
        cout<<"Enter the book id: "<<endl;
  cin>>bookdetail.book_Id;
        cout<<"Enter the book Title:"<<endl;
        cin>>bookdetail.book_Title;
        cout<<"Enter the book author:"<<endl;
        cin>>bookdetail.book_Author;
        cout<<"Enter the book price:"<<endl;
  cin>>bookdetail.book_Cost;
  libraryp[arrayposition]=bookdetail;
  arrayposition++;
  
    }
    void displaybooks(){
        for(int i=0; i<5; i++){
         book displayitem=libraryp[i];
         if(displayitem.book_Id!=0){
     
         cout<<"book id is     :"<<displayitem.book_Id<<endl;
         cout<<"book Title is  :"<<displayitem.book_Title<<endl;
         cout<<"book author is :"<<displayitem.book_Author<<endl;
         cout<<"book cost is   :"<<displayitem.book_Cost<<endl;
          }
     }
    }
    void book_author(){
     string searchauthor;
   cin >> searchauthor;
     for(int i=0; i<5; i++){
         book displayitem=libraryp[i];
         
         string s =searchauthor;  
      int n = s.length();  
      char author[n + 1]; 
      strcpy(author, s.c_str()); 
         
         
         string st =displayitem.book_Author;  
      int ln = st.length();  
      char bookauthor[ln + 1]; 
      strcpy(bookauthor, st.c_str()); 
         
         if(strcmp(author,bookauthor)==0){ 
         cout<<"book id is    : "<<displayitem.book_Id<<endl;
         cout<<"book Title is : "<<displayitem.book_Title<<endl;
         cout<<"book author is: "<<displayitem.book_Author<<endl;
         cout<<"book cost is  : "<<displayitem.book_Cost<<endl;
          }
     }
        
    }
    void count_book(){
     int count=0;
     for(int i=0; i<5; i++){
         book displayitem=libraryp[i];
         if(displayitem.book_Id!=0){
          count++;
       }
   }
        cout<< "Total No of books in library:   "<<count<<endl;
    }

 int main()
{
 while(true){
  cout<<"    ********Library Record System*******"<<endl;
  cout<<"press 1 to enter book record."<<endl;
  cout<<"press 2 to Display all record available in library."<<endl;
  cout<<"press 3 to Search Books by Author Name."<<endl;
  cout<<"press 4 Count Total Books in Library."<<endl;
  cout<<"press 5 Exit from the System."<<endl;
   cout<<"Enter Choise:  "<<endl;
  int choise;
  cin>>choise;
  switch(choise){
  case 1:
  addbooks(); 
  break;
  case 2:
  displaybooks(); 
  break;
  case 3: 
  book_author();
  break;
  case 4:
  count_book();
  break;
  case 5:
   exit(0);
  }
 }

cin.get();
}

CS201 Assignment Solution Code Explanation




CS201 Assignment no 3 Solution Output Preview

You can Test Solution Output via Online C++ Compiler: Click Here

CS201 Assignment No 3 Solution output Spring 2019 Preview
CS201 Assignment No 3 Solution output Spring 2019 Preview
Recommended:

CS201 Assignment Solution Download Link

Download  [ Solution File Upload Status : Done ]

Post a Comment

 

Top