library.h
#ifndef LIBRARY_H
#define LIBRARY_H
#include<iostream>
using namespace std;
//Library class
class Library
{
public:
//public members
Library();
static const int MAX = 100;
int findBook(const string&
name) const;
void addBook(const string&
name);
void removeBook(const string&
name);
void listOfBooks();
private:
//private members
int numberOfBooks;
string books[MAX];
};
#endif
library.cpp
#include<iostream>
#include "library.h"
using namespace std;
//constructor
Library::Library()
{
numberOfBooks=0;
}
// find a book
int Library::findBook(const string& name) const
{
for(int i=0; i<numberOfBooks; i++)
{
if(books[i]==name) return i;
}
return -1;
}
// add a book
void Library::addBook(const string& name)
{
if(numberOfBooks<MAX)
{
books[numberOfBooks] = name;
numberOfBooks++;
}
else
{
cout<<"Failed to add a
book"<<endl;
}
}
//remove a book
void Library::removeBook(const string& name)
{
int i = findBook(name);
if(i==-1)
cout<<"Book not
found"<<endl;
else{
books[i] =
books[numberOfBooks-1];
numberOfBooks--;
}
}
// list of books
void Library::listOfBooks()
{
for(int i=0; i<numberOfBooks; i++)
cout<<books[i]<<"
";
}
main.cpp
#include <iostream>
#include "library.h"
using namespace std;
//main function
int main()
{
Library ob;
//add books
ob.addBook("A");
ob.addBook("B");
ob.addBook("C");
ob.addBook("D");
//list of books
cout<<"\nlist of books before remove a
book:"<<endl;
ob.listOfBooks();
//remove a book
ob.removeBook("B");
//list of books
cout<<"\nlist of books after remove a
book:"<<endl;
ob.listOfBooks();
return 0;
}
Output:
list of books before remove a book:
A B C D
list of books after remove a book:
A D C
9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5...
Challenge: Recursion and Python Turtle Graphics Submit Assignment Due Friday by 11:59pm Points 100 Submitting a file upload Available after Nov 9 at 12am Challenge: Recursion and Python Turtle Graphics Description: Write a program that draws a picture using Python e, recursion, and Turtle graphics e. Purpose: The purpose of this challenge is to provide experience working with recursione in Pythone. It also provides experience working with Turtle graphics in Pythone Requirements: Recursion and Python Turtle Graphics provides information on...
Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm Objective This assignment will consist of writing a program that involves practice with arrays, random number generation, and Strings. You may use c-strings or string objects here, however, string objects is recommended. Exercise Filename: sentences.cpp Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings) called article, noun, verb, and preposition. The arrays...
Part 1 The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class. The class will have the following data members: A string for the name of the author A string for the book title A long integer for the ISBN The class will have the following member functions (details about each one are...
Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit 1 zip file containing 4 files below to iLearn by the deadline. [30 points] ● 3 JAVA Files: TableBmiPro.java, MyOwnIdea.java. DiceRoll.java [24 points] ● 1 File: Make a document that shows the screen captures of execution of your programs and learning points in Word or PDF. Please make sure you capture at least 2 executions for 1 program, so 6 screen captures and one...
A library maintains a collection of books. Books can be added to and deleted from and checked out and checked in to this collection. Title and author name identify a book. Each book object maintains a count of the number of copies available and the number of copies checked out. The number of copies must always be greater than or equal to zero. If the number of copies for a book goes to zero, it must be deleted from the...
Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...
Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...
C++ programming Submit assignment to Blackboard by the midnight on the due date listed above. (Verify if your submission is completed.) The only people you are to discuss this project with are myself and the CS Department tutor. Duplicate code, if discovered, will result in a 0 grade. Your source file(s) should follow the Computer Science Coding Standards (available at the Computer Science Homepage) including proper indenting and spacing 1 Overview program, you will play a game of hangman. In...
Week 5 Case Study: 5.5 (Due week 7) Submit Assignment Due Jul 27 by 11:59pm Points 25 Submitting a text entry box or a file upload Create a non leading multiple choice answer type physician query for the following scenario. A 79-year-old female, Mrs. Carmichael, is admitted on June 15,2015, with a right hip fracture. Her hospital stay is 3 days long. Prior to surgery, her attending physician, Dr. Fellows, orders blood work to check her hemoglobin and hematocrit levels...
Assignment 11 – Exceptions, Text Input/Output - Random Numbers Revised 9/2019 Chapter 12 discusses Exception Handling and Input/Output. Using try/catch/finally statement to handle exceptions, or declare/throw an exception as needed, create the following program: Create an array of 25 random numbers between 0 & 250 formatted to a field width of 10 & 4 decimal places (%10.4f). Use the formula Math.random() * 250. Display the array of random numbers on the console and also write to a file. Prompt the...