Ok so I prompt the user for invoices (Invoice Number, Quantity Shipped, Part Number, Part Description, and Unit Price) until the user gets tired and enters an Invoice Number of 0 for an invoice. After the user enters an Invoice Number of 0, he should not be prompted for any additional invoice info, and the program should enter an “edit mode”. In edit mode, the user is prompted for an invoice number. The program should search for that invoice, display all its current information, and allow the user to change and store each of the values originally entered. To exit “edit mode” (and the program) the user can enter an Invoice Number of 0.
Problem 1: My problem is trying to think of a way to exit the loop incase they enter 0 first or 0 anytime after the first. Am I doing it right with the do..while or is there some other way?
Problem 2: I'm trying to think of a good search algorithm, should I use sequential search?

``````#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

#include "invoice.h"

#define MAX_INVOICES 10000
#define EXIT_CODE       0

int main()
{
Invoice *Invoices = new Invoice[MAX_INVOICES];
int    invoiceNum;
int    qtyShipped;
int    partNum;
string partDescrip;
float  unitPrice;
bool   done = true;

do
{
bool done = true;
cout << "\nEnter an Invoice Number (or " << EXIT_CODE << " to exit):";
cin  >> invoiceNum;
if(invoiceNum == 0)
done = false;
for(int i=0; (i<MAX_INVOICES || done != false); i++)
{
cout << "\nEnter an Invoice Number (or " << EXIT_CODE << " to exit):";
cin  >> invoiceNum;
Invoices[i].setInvoiceNum(invoiceNum);
cout << "\nEnter Quantity Shipped: ";
cin  >> qtyShipped;
Invoices[i].setQtyShipped(qtyShipped);
cout << "\nEnter Part Number: ";
cin  >> partNum;
Invoices[i].setPartNum(partNum);
cout << "\nEnter Part Description: ";
cin  >> partDescrip;
Invoices[i].setPartDecription(partDescrip);
cout << "\nEnter Unit Price: ";
cin  >> unitPrice;
Invoices[i].setUnitPrice(unitPrice);
}

} while (done != false);``````
2
Contributors
1