Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Adapted from Introduction to Programming Using Visual Basic 2012, 9/E, David I.

ID: 3558637 • Letter: A

Question

Adapted from Introduction to Programming Using Visual Basic 2012, 9/E, David I. Schneider.

Inventory Control

Write a menu-driven multiform inventory program for a bookstore with data saved in a text file. (text file contents below)

Each record of the text file should consist of five fields (title, author, category, wholesale price, and number in stock.) (The two categories are fiction and non-fiction.)

At any time, including at load time, the program should display the titles of the books in stock in a listbox (pulled from Books.txt) The user should have the option of displaying either all titles or just those in one of the two categories. The user should be able to add a new book, delete a book, or alter any of the fields of a book in stock. The adding and editing processes use the second form, frmDetails.

At any time, the user should be able to calculate the total value of all books, or the total value of the books in either category. The menu item File contains the two second-level menu items Save and Exit.

The menu items Display and Values each contain the three second-level menu items All, Fiction, and Nonfiction.

(Note: Store the data about the books in an array of structures.)

Helpful Hints:
1. The contents of text file, Books.txt. is included below and should be stored in the project's bindebug folder.

2. You will need only two forms (frmInventory and frmDetails).

3. All functionality is menu-driven on frmInventory.

Note: Make sure a book is selected in the listbox before allowing the user to select Update from the Book menu.

4. Use appropriate naming conventions for controls and provide good internal documentation.

Books.txt Contents

Left Behind,Lahaye,F,7,11.25

A Tale of Two Cities,Dickens,F,100,8.24

Hang a Thousand Trees with Ribbons,Rinaldi,F,30,16.79

Saffy's Angel,McKay,F,20,8.22

Each Little Bird that Sings,Wiles,F,10,7.70

Abiding in Christ,Murray,N,3,12.20

Bible Prophecy,Lahaye and Hindson,N,5,14.95

Captivating,Eldredge,N,12,16

Growing Deep in the Christian Life,Swindoll,N,11,19.95

Prayers that Heal the Heart,Virkler,N,4,12.00

Grow in Grace,Ferguson,N,3,11.95

The Good and Beautiful God,Smith,N,7,11.75

Victory Over the Darkness,Anderson,N,12,16

Explanation / Answer

Public Class Form1 Public bookList As New List(Of Book) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Presumes each book is stored on one line, with data seperated with a ";" 'eg: Wrox Beginning Visual Basic 2010;Thearon Willis;non-fiction;100;17.5 Dim books As String() = IO.File.ReadAllLines("c:ooks.txt") For Each line In books Dim bookdata As String() = line.Split(";") bookList.Add(New Book(bookdata(0), bookdata(1), bookdata(2), CInt(bookdata(3)), CDbl(bookdata(4)))) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'retrieve fiction books Dim fictionBooks As New List(Of Book) fictionBooks = bookList.Where(Function(x) x.category = "fiction").ToList 'retrieve books cheaper than 2.50 Dim discountBooks As New List(Of Book) discountBooks = bookList.Where(Function(x) x.wholesaleprice < 2.5).ToList End Sub End Class Public Class Book Property title As String Property author As String Property category As String Property stock As Integer Property wholesaleprice As Double Public Sub New(ByVal title As String, ByVal author As String, ByVal category As String, ByVal stock As Integer, ByVal wholesaleprice As Double) _title = title _author = author _category = category _stock = stock _wholesaleprice = wholesaleprice End Sub End Class
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote