Book Shop Inventory A book shop uses a personal computer to maintain the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher, stock position, etc. Whenever a customer wants a book, the shopkeeper inputs the title and author of the book and the system replies whether it is in the list or not. If it is not, an appropriate message is displayed. If book is in the list, then the system displays the book details and asks for number of copies. If the requested copies are available, the total cost of the books is displayed; otherwise the message "Required copies not in stock" is displayed. A program to accomplish this is shown in Fig.10.8. The program uses a template to define the structure of the book. Note that the date of publication, a member of record structure, is also defined as a structure. When the title and author of a book are specified, the program searches for the book in the list using the function look_up(table, s1, s2, m) The parameter table which receives the structure variable book is declared as type struct record. The parameters s1 and s2 receive the string values of title and author while m receives the total number of books in the list. Total number of books is given by the expression sizeof(book)/sizeof(struct record) The search ends when the book is found in the list and the function returns the serial number of the book. The function returns -1 when the book is not found. Remember that the serial number of the first book in the list is zero. The program terminates when we respond "NO" to the question Do you want any other book? Note that we use the function get(string) to get title, author, etc. from the terminal. This enables us to input strings with spaces such as "C Language". We cannot use scanf to read this string since it contains two words. Since we are reading the quantity as a string using the get(string) function, we have to convert it to an integer before using it in any expressions. This is done using the atoi() function.

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 3E
icon
Related questions
Question
Book Shop Inventory
A book shop uses a personal computer to maintain the inventory of books that are being sold at
the shop. The list includes details such as author, title, price, publisher, stock position, etc.
Whenever a customer wants a book, the shopkeeper inputs the title and author of the book and
the system replies whether it is in the list or not. If it is not, an appropriate message is displayed.
If book is in the list, then the system displays the book details and asks for number of copies. If
the requested copies are available, the total cost of the books is displayed; otherwise the
message "Required copies not in stock" is displayed.
A program to accomplish this is shown in Fig.10.8. The program uses a template to define the
structure of the book. Note that the date of publication, a member of record structure, is also
defined as a structure.
When the title and author of a book are specified, the program searches for the book in the list
using the function
look_up(table, s1, s2, m)
The parameter table which receives the structure variable book is declared as type struct
record. The parameters s1 and s2 receive the string values of title and author while m receives
the total number of books in the list. Total number of books is given by the expression
sizeof(book)/sizeof(struct record)
The search ends when the book is found in the list and the function returns the serial
number of the book. The function returns -1 when the book is not found. Remember that
the serial number of the first book in the list is zero. The program terminates when we
respond "NO" to the question
Do you want any other book?
Note that we use the function
get(string)
to get title, author, etc. from the terminal. This enables us to input strings with spaces such as "C
Language". We cannot use scanf to read this string since it contains two words.
Since we are reading the quantity as a string using the get(string) function, we have to convert it
to an integer before using it in any expressions. This is done using the atoi() function.
Transcribed Image Text:Book Shop Inventory A book shop uses a personal computer to maintain the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher, stock position, etc. Whenever a customer wants a book, the shopkeeper inputs the title and author of the book and the system replies whether it is in the list or not. If it is not, an appropriate message is displayed. If book is in the list, then the system displays the book details and asks for number of copies. If the requested copies are available, the total cost of the books is displayed; otherwise the message "Required copies not in stock" is displayed. A program to accomplish this is shown in Fig.10.8. The program uses a template to define the structure of the book. Note that the date of publication, a member of record structure, is also defined as a structure. When the title and author of a book are specified, the program searches for the book in the list using the function look_up(table, s1, s2, m) The parameter table which receives the structure variable book is declared as type struct record. The parameters s1 and s2 receive the string values of title and author while m receives the total number of books in the list. Total number of books is given by the expression sizeof(book)/sizeof(struct record) The search ends when the book is found in the list and the function returns the serial number of the book. The function returns -1 when the book is not found. Remember that the serial number of the first book in the list is zero. The program terminates when we respond "NO" to the question Do you want any other book? Note that we use the function get(string) to get title, author, etc. from the terminal. This enables us to input strings with spaces such as "C Language". We cannot use scanf to read this string since it contains two words. Since we are reading the quantity as a string using the get(string) function, we have to convert it to an integer before using it in any expressions. This is done using the atoi() function.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage