Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

This assignment utilizes a class in an application that might be useful in the real world. It requires sorting and computation with data stored in

This assignment utilizes a class in an application that might be useful in the real world. It
requires sorting and computation with data stored in a vector inside a class. In this assignment,
you will design an Object-Oriented program and manipulate data using a vector within the class.
REMINDER
Do not put each class code into a single file.
Review the checklist at the end of the instructions before submitting the assignment.
INSTRUCTIONS
You have been contracted by a bookstore to create an application that will load a list of books
received in a shipment and produce a report about the shipment.
Write a program (client) that uses the class by creating a BooksReceived object and prompting
the user for a file name. (The file is of the type .txt) Appropriate error checking is required to
ensure the file exists and can be opened successfully. Also, the name of the file may contain a
space; therefore, be sure to use getline() instead of cin when you prompt the user to enter the
name of the file. Note: File Name means the path and name of the file.
Class:
Name: BooksReceived
Purpose: To accept and store the data for a list of books that were in a shipment and to provide
functions that will manipulate the data.
Constructor:
Zero-argument constructor that initializes the data members to 0 or as appropriate.
Four-argument constructor that receives the name of the book store, the date shipped, the
number of hardbound books, and the number of paperback books.
Data Members:
nameBookstore string
Cannot be blank.
dateShipped string
Cannot be blank.
numberHardbound int
Must be 1 or greater.
Note: The number of hardbound and paperback books does not have match the number in
the text file.
CSIS 112 Lab 3
Page 2 of 2
numberPaperback int
Must be 1 or greater.
books vector<string>
Functions:
addBook(string)- void
Accepts a book value as a string and adds it to the vector.
sortBookList()- void
Sorts the vector that contains the list of books received.
countBooksReceived() int
Determines the number of books in the vector and returns this.
Do not use a counter of books added.
calcHardboundPercentage() double
Calculates the percentage of the hardbound books in the shipment.
calcPaperbackPercentage() double
Calculates the percentage of the paperback books in the shipment.
setNameBookstore()- void
Accepts a string containing the book store name value and updates the nameBookstore
data member.
getNameBookstore ()- string
Returns the value stored in the nameBookstore data member.
setDateShipped()- void
Accepts a string containing the date shipped value and updates the dateShipped data
member.
getDateShipped()- string
Returns the value stored in the dateShipped data member.
setNumberHardbound()- void
Accepts an int value containing the number of hardboard books in the shipment and
updates the numberHardbound data member.
getNumberHardbound ()- int
Returns the value stored in the numberHardbound data member.
setNumberPaperback()- void
Accepts an int value containing the number of paperback books in the shipment and
updates the numberPaperback data member.
getNumberPaperback ()- int
Returns the value stored in the numberPaperback data member.
displayBooksReceivedInfo() void
Creates and displays the formatted output of the book shipment information.
Note: Setters and Getters are required even if they are not used.
Formulas:
Need: Calculate the percentage of hardbound and paperback books against the total
number of books in the shipment.
CSIS 112 Lab 3
Page 3 of 2
o For the percentage, always display only 1 digit after the decimal point. Some
percentages will not have anything after the decimal point. E.G.,20%,27.3%
o FYI: Some of the percentage values will have no decimal point, and others will
have several digits after the decimal point. The information below will help you
correctly display 0 or 1 digit after the decimal point.
o The formula for calculating the percentage is:
Number of Hardbound books / Total Number of Books *100
Below is a code example for both the calculation and the display.
double x =(3*1.0)/(11*1.0)
3 is the number of books (hardbound or paperback)
11 is the total number of books in the shipment
Multiplying the integer 3 or 11 by 1.0 converts it to a double.
cout << "Hardbound:"<< setprecision(3)<<(0.2727*100.0)<<
"%"<< endl;
Multiplying the 0.2727, which is the calculated percentage, by 100.0 transforms it into 27.27.
The setprecision(3) function above tells the compiler that the data value of 27.27 is to be
displayed with 3 digits. This causes the final digit to be rounded up or down, and the output is
27.3.
Business Rules:
No blank lines are allowed in the text file.
The value for the number of hardbound and paperback books in the shipment mus

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_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students explore these related Databases questions