Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a few bugs that I need help debugging. Can you fix it for me? Coded in C++ Severity Code Description Project File Line

I have a few bugs that I need help debugging. Can you fix it for me? Coded in C++

Severity Code Description Project File Line Suppression State

Warning C4101 'qtyOnHand': unreferenced local variable Project5 c:\users\william\desktop\project5\project5\source.cpp 17

Severity Code Description Project File Line Suppression State

Error C4700 uninitialized local variable 'choice' used Project5 c:\users\william\desktop\project5\project5\source.cpp 113

Severity Code Description Project File Line Suppression State

Error C4700 uninitialized local variable 'choice' used Project5 c:\users\william\desktop\project5\project5\source.cpp 191

#include

#include

#include

#include

#include

#include

using namespace std;

const int SIZE = 20;

int main() {

string author[SIZE];

string publisher[SIZE];

string dateAdded[SIZE];

string isbn[SIZE];

string bookTitle[SIZE];

//int qtyOnHand[SIZE];

char choice = '1';

while (choice > 49 || choice < 52)

{

cout << setw(34) << "Serendipity Bookseller ";

cout << setw(29) << "Main Menu ";

cout << "1. Cashier Module ";

cout << "2. Inventory Database Module ";

cout << "3. Report Module ";

cout << "4. Exit ";

cout << "Enter your choice: ";

cin >> choice;

system("cls");

if (choice < 49 || choice > 52)

{

cout << "please enter a number in range 1 - 4 ";

cout << "Enter your choice again please: ";

cin >> choice;

}

else {

switch (choice)

{

case '1':

cashier();

break;

case '2':

invmenu();

break;

case '3':

reports();

break;

case '4':

cout << "You selected item 4";

return 0;

}

cout << endl << endl;

}

}

system("cls");

system("pause");

return 0;

}

void cashier() {

const double salesTax = 0.06;

double price;

double subtotal;

double tax;

double total;

char again;

string date;

string isbn;

string title;

int quantity;

do

{

cout << "Serendipity Booksellers ";

cout << "Date: ";

getline(cin, date);

cout << "Quantity of books: ";

cin >> quantity;

cin.ignore();

cout << "ISBN: ";

getline(cin, isbn);

cout << "Title :";

getline(cin, title);

cout << "Price: ";

cin >> price;

cout << " ";

subtotal = quantity * price;

tax = subtotal * salesTax;

total = subtotal + tax;

cout << "Qty\tISBN\t\tTitle\t\t\t\tPrice\t\tTotal ";

cout << "_______________________________________________________________________________ ";

cout << quantity << "\t";

cout << left << setw(14) << isbn << "\t";

cout << left << setw(26) << title << "\t$ ";

cout << fixed << showpoint << right << setprecision(2);

cout << setw(6) << price << "\t$ ";

cout << setw(6) << subtotal << " ";

cout << "\t\tSubtotal\t\t\t\t\t\t$ ";

cout << setw(6) << subtotal << " ";

cout << "\t\tTax\t\t\t\t\t\t\t$ ";

cout << setw(6) << tax << " ";

cout << "\t\tTotal\t\t\t\t\t\t\t$ ";

cout << setw(6) << total << " ";

cout << " Thank You For Shopping at Serendipity! ";

cout << "Would you like to process another transaction? (Y/N)";

cin >> again;

cin.ignore();

} while (again == 'Y' || again == 'y');

system("cls");

system("pause");

}

void invmenu()

{

char choice;

while (choice != 3)

{

cout << setw(34) << "Serendipity Booksellers ";

cout << setw(32) << "Inventory Database ";

cout << "\t1. Look-up a Book ";

cout << "\t2. Add a Book ";

cout << "\t3. Edit a Book's Record ";

cout << "\t4. Delete a Book ";

cout << "\t5. Return to the Main Menu ";

cout << "Enter your choice: ";

cin >> choice;

system("cls");

while (choice < 49 || choice > 53)

{

cout << "please enter a number in range 1 - 5 ";

cout << "Enter your choice again please: ";

cin >> choice;

}

switch (choice)

{

case '1':

lookUpBook();

break;

case '2':

addBook();

break;

case '3':

editBook();

break;

case '4':

deleteBook();

break;

case '5':

cout << "You selected item 5, Returning to Main Menu ";

system("pause");

system("cls");

return;

}

cout << endl << endl;

system("cls");

}

}

void lookUpBook()

{

cout << " You have selected Look Up a Book. ";

system("pause");

}

void addBook()

{

cout << " You have selected Add a Book. ";

system("pause");

}

void editBook()

{

cout << " You have selected Edit a Book. ";

system("pause");

}

void deleteBook()

{

cout << " You have selected Delete Book. ";

system("pause");

}

void bookInfo(string isbn[], string bookTitle[], string author[], string publisher[], string dateAdded[], int qtyOnHand[],

double wholesale[], double retail[]) {

cout << setw(39) << "Serendipity Booksellers ";

cout << setw(37) << "Book Information ";

cout << "ISBN: " << isbn << endl;

cout << "Title: " << bookTitle << endl;

cout << "Author: " << author << endl;

cout << "Publisher: " << publisher << endl;

cout << "Date Added: " << dateAdded << endl;

cout << "Quantity-On-Hand: " << qtyOnHand << endl;

cout << "Wholesale Cost: " << wholesale << endl;

cout << "Retail Price: " << retail << endl << endl << endl;

cout << "Enter Your Choice: ";

}

void reports() {

char choice;

while (choice != 5)

{

cout << setw(41) << "Serendipity Booksellers ";

cout << setw(34) << "Reports ";

cout << "1. Inventory Listing ";

cout << "2. Inventory Wholesale Value ";

cout << "3. Inventory Retail Value ";

cout << "4. Listing by Quantity ";

cout << "5. Listing by Cost ";

cout << "6. Listing by Age ";

cout << "7. Return to the Main Menu ";

cout << "Enter your choice: ";

cin >> choice;

system("cls");

while (choice < '1' || choice > '7')

{

cout << "please enter a number in range 1 - 7 ";

cout << "Enter your choice again please: ";

cin >> choice;

system("cls");

}

switch (choice)

{

case '1':

listing();

break;

case '2':

wholesale();

break;

case '3':

retail();

break;

case '4':

quantity();

break;

case '5':

cost();

break;

case '6':

age();

break;

case '7':

cout << "You selected item 7, Returning to Main Menu ";

system("pause");

system("cls");

return;

}

cout << endl << endl;

}

}

void listing()

{

cout << " You have selected Inventory Listing. ";

system("pause");

system("cls");

}

void wholesale()

{

cout << " You have selected Wholesale Value. ";

system("pause");

system("cls");

}

void retail()

{

cout << " You have selected Retail Value. ";

system("pause");

system("cls");

}

void quantity()

{

cout << " You have selected Listing by Quantity. ";

system("pause");

system("cls");

}

void cost()

{

cout << " You have selected Listing by Cost. ";

system("pause");

system("cls");

}

void age()

{

cout << " You have selected Listing by Age. ";

system("pause");

system("cls");

}

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions