Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the following code #include #include #include #include using namespace std; class Book { private: string id; string author; string title; int edition; int year;

image text in transcribedimage text in transcribedimage text in transcribed

Using the following code

#include

#include

#include

#include

using namespace std;

class Book

{

private:

string id;

string author;

string title;

int edition;

int year;

string isbn;

public:

Book();

Book(string id, string author, string title, int edition, int year, string isbn);

string getID()

{return id;}

string getAuthor()

{return author;}

string getTitle()

{return title;}

int getEdition()

{return edition;}

int getYear()

{ return year;}

string getISBN()

{return isbn;}

void setID(string id)

{this->id = id;}

void setAuthor(string author)

{this->author = author;}

void setTitle(string title)

{this->title = title;}

void setEdition(int edition)

{this->edition = edition;}

void setYear(int year)

{this->year = year;}

void setISBN(string isbn)

{this->isbn = isbn;}

friend void Sort(Book bookList[], int size);

friend ostream &operator

};

Book::Book()

{

id = "";

author = "";

title= "";

edition = 0;

year = 0;

isbn = "";

}

Book::Book(string id, string author, string title, int edition, int year, string isbn)

{

id = id;

author = author;

title = title;

this->edition = edition;

this->year = year;

isbn = isbn;

}

void Sort(Book bookList[], int size)

{

for(int i = 0; i

for(int j = i+1; j

if(bookList[i].getTitle() > bookList[j].getTitle())

{

Book temp = bookList[i];

bookList[i] = bookList[j];

bookList[j] = temp;

}

}

ostream &operator

{

output

output

output

output

return output;

}

int main()

{

Book bookList[2000];

string id, author, title, isbn;

int edition =0 , year=0;

int size = 0;

ifstream in;

ofstream out;

in.open("bookinput.dat");

if(!in.is_open())

{

cout

return 0;

}

while (!in.eof())

{

getline(in, id, ',');

if(in.eof())

{break;}

getline(in, author, ',');

getline(in, title, ',');

getline(in, isbn);

bookList[size].setID(id);

bookList[size].setAuthor(author);

bookList[size].setTitle(title);

bookList[size].setEdition(edition);

bookList[size].setYear(year);

bookList[size].setISBN(isbn);

size++;

}

out.open("bookoutput.dat");

Sort(bookList, size);

for(int i = 0; i

out

in.close();

out.close();

}

CSci 1113: Introduction to C/C++ Programming for Scientists and Engineers Spring 2018 Homework 9 Due Date: Friday, April 20, 2018 at 6:00pm. Instructions: This is an individual homework assignment. There is one problem worth 20 points. Solve the problem by yourself (unlike the labs, where you can work collaboratively), and submit the solution as a C++source code file. Here are a few more important details: You submit the correct file through Canvas by the due deadline . You should follow the example input and output formats given in each problem description (match the input and output format exactly) Regardless of how or where you develop your solutions, your programs compile and execute on cselabs computers running the Linux operating system Problem A "Beefier" Book Database This homework will carry on our work on the book database. A solution file for homework 8 is going to be provided, in case you need it. However, you are not required to use this, as long as your own solution is complete and 100% correct as per the requirements of homework 8. 1. Program Tasks ("What do I have to do exactly?") In this homework, you will extend your book database in the following way 1. Split the code into a header (hpp), a source (cpp) and a driver file (containing mainO); 2. Perform multiple operations on the book records, described below. 3. Use a basic "menu system" to prompt the user for their choice of operation. These are: a) Add a new record from keyboard input, to be added to the end of the array of book objects in memory; b) Find a record using the author name (print "record not found" if the record does not exist), and display it on the screen. If there are multiple records that have the same author name, you have to display all those that match; c) Display all records from the input file on the screen; d) Choose a sorting criterion to sort the records, and send them to the output file and to the screen at the same time. Unlike homework 8, we will be not only sorting on book title, but we want to have the ability to sort on any field in the record. That is, the output file can be sorted on author name, or title, or edition, or publication year, or ISBN, or ID. The user will choose what field he/she wants to sort the records on. e) Quit the program. 2. Input/output specifications: The input file specification is the same as the one from homework 8. See later in this file for an example input file. Keep in mind that in this homework, the "input" file will also have to be written to at the end of the program. You have to handle this case accordingly CSci 1113: Introduction to C/C++ Programming for Scientists and Engineers Spring 2018 Homework 9 Due Date: Friday, April 20, 2018 at 6:00pm. Instructions: This is an individual homework assignment. There is one problem worth 20 points. Solve the problem by yourself (unlike the labs, where you can work collaboratively), and submit the solution as a C++source code file. Here are a few more important details: You submit the correct file through Canvas by the due deadline . You should follow the example input and output formats given in each problem description (match the input and output format exactly) Regardless of how or where you develop your solutions, your programs compile and execute on cselabs computers running the Linux operating system Problem A "Beefier" Book Database This homework will carry on our work on the book database. A solution file for homework 8 is going to be provided, in case you need it. However, you are not required to use this, as long as your own solution is complete and 100% correct as per the requirements of homework 8. 1. Program Tasks ("What do I have to do exactly?") In this homework, you will extend your book database in the following way 1. Split the code into a header (hpp), a source (cpp) and a driver file (containing mainO); 2. Perform multiple operations on the book records, described below. 3. Use a basic "menu system" to prompt the user for their choice of operation. These are: a) Add a new record from keyboard input, to be added to the end of the array of book objects in memory; b) Find a record using the author name (print "record not found" if the record does not exist), and display it on the screen. If there are multiple records that have the same author name, you have to display all those that match; c) Display all records from the input file on the screen; d) Choose a sorting criterion to sort the records, and send them to the output file and to the screen at the same time. Unlike homework 8, we will be not only sorting on book title, but we want to have the ability to sort on any field in the record. That is, the output file can be sorted on author name, or title, or edition, or publication year, or ISBN, or ID. The user will choose what field he/she wants to sort the records on. e) Quit the program. 2. Input/output specifications: The input file specification is the same as the one from homework 8. See later in this file for an example input file. Keep in mind that in this homework, the "input" file will also have to be written to at the end of the program. You have to handle this case accordingly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

Logic 2010 Deriv 2.00h

Answered: 1 week ago