You are to create a program that can be used for keeping track of textbooks requ
ID: 3820677 • Letter: Y
Question
You are to create a program that can be used for keeping track of textbooks required and recommended for classes and the cost of those textbooks.
All input will be taken from standard input. Each line of input will begin with a single or double character code that identifies the type of operation that line describes. The possible line formats are:
B <ISBN> <Title>
- Define a book. The ISBN is a 13 digit number. The Title is a string of arbitrary length (ending
with a line break).
e.g.: B 1234567890123 Programming for Programmers
D <ISBN> <A E D> <value>
Define a characteristic of a book (for the book with the given ISBN. If 'A' is used, then the Author is set, and the value is name of the author (string of arbitrary length, ending with end of line). If 'E' is used, the value is the number of the edition (a positive integer). If D is used, it is the date of publication, where the date is in MM/YYTV format (no day). e.g.: D 1234567890123 D 01/2017
M <ISBN> <Cost> <N IUIRI E>
Define the cost for a book. ISBN is the ISBN number, Cost is an amount, expressed as a floating-point number with 2 spaces after the decimal point. The final letter indicates whether the price is for a New, Used, Rented, or Electronic version of the book. A book may have a different price for each format.
e.g.: M 1234567890123 39.99 N
C <Department Code> <Course Number> <Name>
- Define a course. The Department Code is a 4 letter code for a department. The course number is a 3-digit number for the course. The name is a name for the course — a string of arbitrary length, ended by the end of the line.
e.g.: C CSCE 315 Programming Studio
A <ISBN> <Department Code> <Course Number> <Section Number> <R I 0>
Assign a book to a class. The ISBN is the ISBN number for the book. The Department Code and Course number are as in the definition of a course. The section number is a 3 digit integer. The final digit is either R for required or 0 for optional.
e.g.: A 1234567890123 CSCE 315 501 R
GC <Department Code> <Course Number>
-Print the books required and optional for all sections of a given course
GS <Department Code> <Course Number> <Section Number>
-Print the books required and optional for a given section of a course
GB <ISBN>
-Print all information known about a particular book
PB
-Print a list of all books that are defined
PC
-Print a list of all courses that are defined
PY <Mm/yrry>
- Print all books with known publication dates in the given month/year or later.
PD <Department Code>
- Print the list of all books used in a department, given by department code. Do not list by section.
PM <Department Code>
Print the AVERAGE minimum and maximum costs of all books in a department. Minimum cost is
the cost of the cheapest version of required books for a section. Maximum cost is the cost of
the most expensive required and optional books in a course. If a book has no known costs,
ignore it. The average is the average across all sections in a department for which there is some
required or optional book.
Notes:
The program should be developed in C++
-Books will be defined before details or costs are added
-Books and courses will be defined before books are added to courses.
-Note that later lines can overwrite information from previous lines. For example, a price could
be updated, an edition number could change, etc. The last of the input lines should be the one
used.
-Printed lists should be reasonably informative, with all information provided possible (e.g. when
printing a book, print the title, author (if known), costs (if known), etc.
----------------------------------------------------------------------------------------------------------------------------------------------
TEST inputs below can be used to test the programs functionality(Note: this stuff needs to be in a test.txt file and possible run a command such "./main < test.txt" but you can test it your way to.) :
TEST data that can be used to test each of the input formats:
B 1234567890123 Programming for Pros
B 1234567890124 Programming for Dummies
B 1234567890125 Programming for Pets
D 1234567890123 D 02/2017
D 1234567890123 A King of Stupid
D 1234567890123 E 5
D 1234567890124 D 05/2017
D 1234567890124 A Ray
D 1234567890124 E 2
D 1234567890125 D 03/2017
D 1234567890125 A James
D 1234567890125 E 3
M 1234567890123 1 N
M 1234567890123 1 U
M 1234567890123 1 R
M 1234567890123 1 E
M 1234567890124 1 N
M 1234567890124 1 U
M 1234567890124 1 E
M 1234567890124 1 R
M 1234567890125 1 N
M 1234567890125 1 U
M 1234567890125 1 R
M 1234567890125 1 E
C ECEC 215 Programming Studio
C ECEC 111 Unix Testing
A 1234567890123 ECEC 215 501 R
A 1234567890123 ECEC 215 502 R
A 1234567890123 ECEC 215 503 R
A 1234567890124 ECEC 213 604 R
A 1234567890124 ECEC 213 607 R
A 1234567890124 ECEC 213 603 R
A 1234567890125 ECEC 215 501 R
A 1234567890125 ECEC 215 502 R
A 1234567890125 ECEC 215 503 R
GC ECEC 215
GS ECEC 215 504
GC ECEC 111
GS ECEC 111 605
GB 1234567890123
GB 1234567890124
GB 1234567890125
PB
PC
PY 02/2017
PY 05/2017
PD ECEC
PM ECEC
Explanation / Answer
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
const unsigned TABLE_SIZE=200;
int main() {
string filename;
int option;
string Title = getTitle();
cout<<"Enter filename";
cin>>filename;
cout<<" Select an option from the menu: ";
cout<<"1)Insert a new book into the list";
cout<<"2)Print the info of a specific book by ISBN number ";
cout<<"3)Print the list sorted by ISBN ";
cout<<"4)Print the list sorted alphabetically by title";
cout<<"5)Quit the program";
cout<<"Please select an option";
cin>>option;
if(option==1) {
cout<<"Enter book's title";
cin>>Title;
cout<<"Enter author's name " ;
cin>>Author;
cout<<"Enter book's publisher";
cin>>Publisher;
cout<<"Enter book's ISBN";
cin>>Isbn;
}
else if( option==2) {
cout<<"Enter ISBN";
cin>>Isbn;
}
else if(option==3) {
cout<<" Title Author publisher ISBN";
cout<<" ---------------------- ---------------------- ---------------------- ---------- " ;
}
else if( option==4) {
cout<<" Title Author publisher ISBN";
cout<<" ---------------------- ---------------------- ---------------------- ---------- " ;
}
else
cout<<"You have quit the program";
class BookRecord {
string Title ;
string Author ;
string Publisher ;
int Isbn;
public :
BookRecord() {
}
string BookRecord ::getTitle (){
return Title;
}
string BookRecord::getAuthor() {
return Author;
}
string BookRecord::getPublisher() {
return Publisher;
}
void BookRecord ::Title (string s){
Title = s;
}
void BookRecord::Author( string a) {
Author = a;
}
void BookRecord::Publisher(string p) {
Publisher = p;
class ListRecords {
ListRecords(filename) {
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.