This must be in C++. Create a struct that defines a new type BookType. It should
ID: 3683484 • Letter: T
Question
This must be in C++.
Create a struct that defines a new type BookType. It should store the following about a book:
The author of the book
The title
The book's ISBN, a 10-character code that uniquely identifies a book
The book's publication year
The book's list price in dollars
Whether the book is hardcover or paperback.
Create a main program. In the main program, create two instances of bookType. Then fill up each record with valid information about two different books, where one is paperback and one is not.
You may simply hardcode this information with assignment statements.
The bookstore is having a sale on paperback books; they're all 10% off.
Check both books and change the prices on the paperbacks.
you could hardcode the records, but you should assume you don't know what they store and write your code generally.
Then figure out which book is cheaper.
Again, assume you don't know what's stored in records.
Print out the title, author, and price of the cheaper book.
Explanation / Answer
Create a struct that defines a new type BookType. It should store the following about a book:
The author of the book
The title
The book's ISBN, a 10-character code that uniquely identifies a book
The book's publication year
The book's list price in dollars
struct book // declare class
{
int no;
string author; // type name of string
string book; // type name of string
string genre; // type name of string
book* next; // type name of string
book()
{
no=0;
author=book=genre=" ";
next=NULL; // next given FALSE value
}
void setnext(book *t)
{
next=t;
}
book* getnext()
{
return next;
}
};
class linklist
{
book *start;
book *current;
public:
linklist()
{
start=NULL;
current=NULL;
}
void insert(book *tmp)
{
if(start==NULL)
{
start=tmp;
}
else
{
current=start;
while(current->getnext()!=NULL)
{
current=current->getnext();
}
current->setnext(tmp);
}
}
bool search_no(int value)
{
current=start;
while(current!=NULL)
{
if(current->no==value)
{
cout<<current->author<<endl;
cout<<current->book<<endl;
cout<<current->genre<<endl;
cout<<"---------------------------------------------- --------------------------"<<endl;
return true;
}
else
current=current->getnext();
}
return false;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.