1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
/******************** HEADER.h ***********************************************/
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include "cashier.h"
#include "invmenu.h"
#include "bookinfo.h"
#include "reports.h"
extern const int ROWS=20;
extern char bookTitle[ROWS][51],
isbn[ROWS][14],
author[ROWS][31],
publisher[ROWS][31],
dateAdded[ROWS][11];//MM-DD-YYYY
extern int qtyOnHand[(ROWS+1)];
extern double wholesale[(ROWS+1)],
retail[(ROWS+1)];
#endif
/********************** invmenu.h ********************************************/
#ifndef INVMENU_H
#define INVMENU_H
#include<iostream>
#include<iomanip>
#include<fstream>
void invMenu();
void lookUpBook();
void addBook();
void editBook();
void deleteBook();
#endif
/************************* invmenu.txt ***********************************/
Gone with the Wind
0-333-90123-8
jack me-off
killer weed inc.
03-01-1954
10
69.99
79.99
/************************* invmenu.cpp ***********************************/
#include "invmenu.h"
#include "header.h"
using namespace std;
void invMenu()
{
int inv_choice;
do
{
cout<<"Serendipity Booksellers"<<endl;
cout<<"\t Inventory Database"<<endl<<endl;
cout<<"1. Look Up a Book"<<endl;
cout<<"2. Add a Book"<<endl;
cout<<"3. Edit a Book's Record"<<endl;
cout<<"4. Delete a Book"<<endl;
cout<<"5. Return to the Main Menu"<<endl<<endl;
cout<<"\t Enter Your Choice: ";
cin>>inv_choice;
cout<<endl<<endl;
switch(inv_choice)
{
case 1: lookUpBook();
break;
case 2: addBook();
break;
case 3: editBook();
break;
case 4: deleteBook();
break;
case 5: return;
break;
default: cout<<"\a Please enter a number in the range 1-5."<<endl<<endl<<endl;
}
}while(inv_choice!=5);
return;
}
/******************************** add book ************************************/
void addBook()
{
int index=-1;
for(int count=0 ; count<(ROWS-1) ; count++)
{
if(!bookTitle[count][0])
{
index=count;
break;
}
}
if(index==-1)
{
cout<<"\a\t No more bookes may be added to the inventory"<<endl;
return;
}
/******************************* cin *************************************/
/*
cout<<"\t Please enter the book title: ";
cin.getline(bookTitle[index],50);
cout<<endl;
cout<<"\t Please enter the ISBN number: ";
cin.getline(isbn[index],13);
cout<<endl;
cout<<"\t Please enter the authors Name: ";
cin.getline(author[index],30);
cout<<endl;
cout<<"\t Please enter the publisher name: ";
cin.getline(publisher[index],30);
cout<<endl;
cout<<"\t Please enter the date the book was added in the form MM-DD-YYYY: ";
cin.getline(dateAdded[index],10);
cout<<endl;
cout<<"\t Please enter the quantity: ";
cin>>qtyOnHand[index];
cout<<endl;
cout<<"\t Please enter the wholesale cost: ";
cin>>wholesale[index];
cout<<endl;
cout<<"\t Please enter the retail price: ";
cin>>retail[index];
cout<<endl;
/****************************** inFile ***********************************/
ifstream inFile("inv_menu.txt");
if (!inFile)
{
cout<<"Could not open file";
return;
}
cout<<"\t Please enter the book title: ";
inFile.getline(bookTitle[index],50);
cout<<endl;
cout<<"\t Please enter the ISBN number: ";
inFile.getline(isbn[index],13);
cout<<endl;
cout<<"\t Please enter the authors Name: ";
inFile.getline(author[index],30);
cout<<endl;
cout<<"\t Please enter the publisher name: ";
inFile.getline(publisher[index],30);
cout<<endl;
cout<<"\t Please enter the date the book was added in the form MM-DD-YYYY: ";
inFile.getline(dateAdded[index],10);
cout<<endl;
cout<<"\t Please enter the quantity: ";
inFile>>qtyOnHand[index];
cout<<endl;
cout<<"\t Please enter the wholesale cost: ";
inFile>>wholesale[index];
cout<<endl;
cout<<"\t Please enter the retail price: ";
inFile>>retail[index];
cout<<endl;
inFile.close();
/*************************** end input ***********************************/
return;
}
/************************* bookinfo.cpp ***********************************/
#include "bookinfo.h"
using namespace std;
void bookInfo(char isbn[14], char title[51], char author[31], char publisher[31],
char date[11], int qty, double wholesale, double retail)
{
int count=0;
cout<<"Serendipity Booksellers"<<endl;
cout<<"\t Book Information"<<endl<<endl;
cout<<"\t ISBN: ";
for (count=0 ; count <13 ; count++)
cout<<isbn[count];
cout<<endl;
cout<<"\t Title: ";
for (count=0 ; count <50 ; count++)
cout<<title[count];
cout<<endl;
cout<<"\t Author: "<<endl;
for (count=0 ; count <30 ; count++)
cout<<author[count];
cout<<endl;
cout<<"\t Publisher: "<<endl;
for (count=0 ; count <30 ; count++)
cout<<publisher[count];
cout<<endl;
cout<<"\t Date Added: "<<endl;
for (count=0 ; count <10 ; count++)
cout<<date[count];
cout<<endl;
cout<<"\t Quantity-On-Hand: "<<qty<<endl;
cout<<"\t Wholesale Cost: "<<wholesale<<endl;
cout<<"\t Retail Price: "<<retail<<endl;
return;
}
/************************* bookinfo.h ***********************************/
#ifndef BOOKINFO_H
#define BOOKINFO_H
#include <iostream>
void bookInfo(char[14], char[51], char[31], char[31],
char[11], int, double, double);
#endif
|