#include "bookType.h"
#include "memberType.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
string ID;
string firstName;
string lastName;
int booksPurchasedRecently;
double amountSpentRecently;
int booksPurchased;
double amountSpent;
string title;
int noOfAuthors;
string authors[];
string publisher;
int year;
string ISBN;
double price;
int quantityInStock;
int quantitySold;
string s;
int start, end;
int main()
{
char choice; // Menu
int x; // Item on list
cout << "To make a selection, input one of the numbers and press enter." << endl;
cout << "(1) Book/ISBN List" << endl;
cout << "(2) Book Information" << endl;
cout << "(3) Member ID/Name List" << endl;
cout << "(4) Member Information" << endl;
cout << "(5) Book Purchase" << endl;
cout << "(9) Exit" << endl;
cout << ">> ";
cin >> choice;
while(choice != '9'){
switch(choice){
case '1': cout << " Book List " << endl;
break;
case '2': cout << " Enter the ISBN for Book Information: " << endl;
break;
case '3': cout << " Member List " << endl;
break;
case '4': cout << " Enter Member ID Number To Continue " << endl;
break;
case '5': cout << " Book Purchase! " << endl;
case '9': break;
default: cout << "Error: Invalid choice" << endl;
}// End of break
cout << "To make a selection, input one of the numbers and press enter." << endl;
cout << "(1) Book/ISBN List" << endl;
cout << "(2) Book Information" << endl;
cout << "(3) Member ID/Name List" << endl;
cout << "(4) Member Information" << endl;
cout << "(5) Book Purchase" << endl;
cout << "(9) Exit" << endl;
cout << ">> ";
cin >> choice;
} // End of loop
bookType bType;
bType.setBookInfo(title, noOfAuthors, authors[10], publisher, year, ISBN, price, quantityInStock, quantitySold);{
ifstream infile;
string fname;
cout << "Enter file name: ";
cin >> fname;
infile.open(fname.c_str());
if(!infile) {
cerr << "Error: Can't open file." << endl;
return 1;
}
else
{
for(int i = 0; i < 100; ++i){
infile>>title;
do {
start = 0;
end = s.find(";");
if(end >= 0) {
cout << s.substr(start, end - start) << endl;
start = end + 1;
s = s.substr(start, s.length() - start);
infile>>noOfAuthors;
}
else
cout << s << endl;
} while(end >= 0);
infile>>authors[noOfAuthors];
infile>>publisher;
infile>>year;
infile>>ISBN;
infile>>price;
infile>>quantityInStock;
infile>>quantitySold;
cout << "Title of Book: " << title << endl;
cout << "Authors: " << authors[noOfAuthors] << endl;
cout << "Publisher: " << publisher << endl;
cout << "Year: " << year << endl;
cout << "ISBN: " << ISBN << endl;
cout << "Price: $ " << price << endl;
cout << "Quantity In Stock: " << quantityInStock << endl;
cout << "Quantity Sold: " << quantitySold << endl;
cout << " " << endl;
}
}
infile.close();
}
memberType mType;
mType.setMemberInfo(ID, firstName, lastName, booksPurchasedRecently, amountSpentRecently, booksPurchased, amountSpent);{
ifstream infile;
string fname;
cout << "Enter file name: ";
cin >> fname;
infile.open(fname.c_str());
if(!infile) {
cerr << "Error: Can't open file." << endl;
return 1;
}
else
{
for(int i = 0; i < 4; ++i){
infile>>ID;
infile>>firstName;
infile>>lastName;
infile>>booksPurchasedRecently;
infile>>amountSpentRecently;
infile>>booksPurchased;
infile>>amountSpent;
cout << "ID: " << ID << endl;
cout << "Name: " << firstName << " " << lastName << endl;
cout << "Books Purchased Recently: " << booksPurchasedRecently << endl;
cout << "Amount Spent Recently: $" << amountSpentRecently << endl;
cout << "Books Purchased Total: " << booksPurchased << endl;
cout << "Amount Spent: $" << amountSpent << endl;
cout << " " << endl;
}
}
infile.close();
}
return 0;
}
Just want to store all seperate infiles into two arrays member and booklist. would this work?
const int M = 100; // M for members const int B = 1000; // B for booklist M = setMemberInfo(); B = setBookInfo();
and how would I link it to the Menu?
Thanks In Advance!

New Topic/Question
Reply



MultiQuote



|