moe45673

Assignment1

Sep 25th, 2011
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. // ISBN Processor
  2. // OOP244.111 - Assignment 1
  3. // a1main.cpp
  4. // Version 1.1
  5. // Chris Szalwinski
  6. // Jan 14 2011
  7.  
  8. #include <iostream>
  9. #include <iomanip>
  10. #include <cstring>
  11. using namespace std;
  12.  
  13. #define  PREFIX_LIST "prefixRanges.txt"
  14. #include "ISBNPrefix.h"
  15. //#include "ISBN.h"
  16.  
  17. int main()
  18. {
  19.     int keepgoing;
  20.     char isbn[11];
  21.     FILE* prefixFile = NULL;
  22.     char area[6], publisher[8], title[7];
  23.  
  24.     cout << "ISBN Processor\n"
  25.          << "==============\n";
  26.  
  27.     prefixFile = open(PREFIX_LIST);
  28.  
  29.     if (prefixFile == NULL)
  30.         cerr << "Could not open file " << PREFIX_LIST << endl;
  31.  
  32.     else
  33.     {   /*
  34.         keepgoing = 1;
  35.         do
  36.         {
  37.             cout << "ISBN (0 to quit) : ";
  38.             cin.getline(isbn, 11);
  39.             if (!cin)
  40.             {
  41.                 cin.clear();
  42.                 cin.ignore(2000, '\n');
  43.                 cerr << "Error. Try Again " << endl;
  44.             }
  45.  
  46.             else if (strcmp(isbn, "0") == 0)
  47.             {
  48.                 keepgoing = 0;
  49.             }
  50.  
  51.             else if (strlen(isbn) != 10)
  52.             {
  53.                 cerr << " Incorrect number of digits. Try again." << endl;
  54.             }
  55.  
  56.             else if (isValid(isbn) == 0)
  57.             {
  58.  
  59.             cerr << " Invalid check digit. Try again." << endl;
  60.             }
  61.  
  62.             else if (isRegistered(prefixFile, isbn, area, publisher,
  63.             title) == 0)
  64.             {
  65.                 cerr << " This ISBN does not have a registered prefix."
  66.                 << endl;
  67.             }
  68.  
  69.             else
  70.             {
  71.                 cout << " Area            : " << area << endl;
  72.                 cout << " Publisher       : " << publisher << endl;
  73.                 cout << " Title           : " << title << endl;
  74.             }
  75.  
  76.             cout << endl;
  77.  
  78.         } while (keepgoing == 1);
  79.         */
  80.         close(prefixFile);
  81.  
  82.         cout << "Signing off ... " << endl;
  83.     }
  84.  
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment