G
GRoll21
The problem starts during my while loop. It checks to see if they hit x
or X. If they did, then that means the user wants to exit. Then should
go on and hit the return statement. It just quits. When I hit x, it
pauses for a second then just goes to the next line on the cmd prompt.
My other returns work just fine though. I'm sure its just a stupid
logical error somewhere that I havn't caught. If anyone can point out
any tips that or whats wrong with it that would be great. Thanks again
to all!
int editBook(int a)
{
///////used to hold new values///
char xisbn[14];
char xtitle[51];
char xauthor[51];
char xpublisher[31];
char xdate[11];
int xqty;
float xwholeSale;
float xretail;
/////////////////////////////////
char change ='z';
char lookUp[51];
bool found = false;
system("cls");
cout << "\n\t\tEnter the title of the book you wish to edit ";
cin >> lookUp;
system("cls");
for(int index = 0; index < 20 && !found; index++)
{
// toupper
char up1[51], up2[51];
for(int position=0; position < 51; position++)
{
up1[position] = toupper(lookUp[position]);
up2[position] = toupper(bookTitle[index][position]);
}
if (strcmp(up1, up2) == 0)
{
found = true;
bookinfo(isbn[index], bookTitle[index], author[index],
publisher[index], dateAdded[index], qtyOnHand[index], wholesale[index],
retail[index]);
}
}
if(!found)
{
cout << "Book not in Inventory";
return 0;
}
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
while (change != 'x' || change!='X')
{
if (change == 'I' || change =='i')
{ cin.ignore();
cout << "Enter the new ISBN number: ";
cin.getline(xisbn,14);
strcpy(isbn[index], xisbn);
cout << "The isbn is now " << isbn[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'T' || change =='t')
{
cin.ignore();
cout << "Enter the new Title: ";
cin.getline(xtitle,51);
strcpy(bookTitle[index], xtitle);
cout << "The title is now " << bookTitle[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'A' || change =='a')
{
cin.ignore();
cout << "Enter the new Author: ";
cin.getline(xauthor,51);
strcpy(author[index], xauthor);
cout << "The author is now " << author[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'P' || change =='p')
{
cin.ignore();
cout << "Enter the new Publisher: ";
cin.getline(xpublisher,31);
strcpy(publisher[index], xpublisher);
cout << "The publisher is now " << publisher[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'D' || change =='d')
{
cin.ignore();
cout << "Enter the new Date: ";
cin.getline(xdate,11);
strcpy(dateAdded[index], xdate);
cout << "The date is now " << dateAdded[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'Q' || change =='q')
{
cout << "Enter the new Quantity on Hand: ";
cin >> xqty;
qtyOnHand[index] = xqty;
cout << "The Quantity on Hand is now " << qtyOnHand[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'W' || change =='w')
{
cout << "Enter the new Whole Sale: ";
cin >> xwholeSale;
wholesale[index] = xwholeSale;
cout << "The Whole Sale is now " << wholesale[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'R' || change =='r')
{
cout << "Enter the new Retail: ";
cin >> xretail;
retail[index] = xretail;
cout << "The retail is now " << retail[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
}
return 0;
}
or X. If they did, then that means the user wants to exit. Then should
go on and hit the return statement. It just quits. When I hit x, it
pauses for a second then just goes to the next line on the cmd prompt.
My other returns work just fine though. I'm sure its just a stupid
logical error somewhere that I havn't caught. If anyone can point out
any tips that or whats wrong with it that would be great. Thanks again
to all!
int editBook(int a)
{
///////used to hold new values///
char xisbn[14];
char xtitle[51];
char xauthor[51];
char xpublisher[31];
char xdate[11];
int xqty;
float xwholeSale;
float xretail;
/////////////////////////////////
char change ='z';
char lookUp[51];
bool found = false;
system("cls");
cout << "\n\t\tEnter the title of the book you wish to edit ";
cin >> lookUp;
system("cls");
for(int index = 0; index < 20 && !found; index++)
{
// toupper
char up1[51], up2[51];
for(int position=0; position < 51; position++)
{
up1[position] = toupper(lookUp[position]);
up2[position] = toupper(bookTitle[index][position]);
}
if (strcmp(up1, up2) == 0)
{
found = true;
bookinfo(isbn[index], bookTitle[index], author[index],
publisher[index], dateAdded[index], qtyOnHand[index], wholesale[index],
retail[index]);
}
}
if(!found)
{
cout << "Book not in Inventory";
return 0;
}
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
while (change != 'x' || change!='X')
{
if (change == 'I' || change =='i')
{ cin.ignore();
cout << "Enter the new ISBN number: ";
cin.getline(xisbn,14);
strcpy(isbn[index], xisbn);
cout << "The isbn is now " << isbn[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'T' || change =='t')
{
cin.ignore();
cout << "Enter the new Title: ";
cin.getline(xtitle,51);
strcpy(bookTitle[index], xtitle);
cout << "The title is now " << bookTitle[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'A' || change =='a')
{
cin.ignore();
cout << "Enter the new Author: ";
cin.getline(xauthor,51);
strcpy(author[index], xauthor);
cout << "The author is now " << author[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'P' || change =='p')
{
cin.ignore();
cout << "Enter the new Publisher: ";
cin.getline(xpublisher,31);
strcpy(publisher[index], xpublisher);
cout << "The publisher is now " << publisher[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'D' || change =='d')
{
cin.ignore();
cout << "Enter the new Date: ";
cin.getline(xdate,11);
strcpy(dateAdded[index], xdate);
cout << "The date is now " << dateAdded[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'Q' || change =='q')
{
cout << "Enter the new Quantity on Hand: ";
cin >> xqty;
qtyOnHand[index] = xqty;
cout << "The Quantity on Hand is now " << qtyOnHand[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'W' || change =='w')
{
cout << "Enter the new Whole Sale: ";
cin >> xwholeSale;
wholesale[index] = xwholeSale;
cout << "The Whole Sale is now " << wholesale[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'R' || change =='r')
{
cout << "Enter the new Retail: ";
cin >> xretail;
retail[index] = xretail;
cout << "The retail is now " << retail[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
}
return 0;
}