Guest User

Untitled

a guest
Apr 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.66 KB | None | 0 0
  1. USER ENTER IF TITLE/ISBN CORRECT (Y/N)
  2. IF Y, CHECK WHETHER THE BOOK IS  AVAILABLE
  3. //boolean isBookAvailable(num ISBN);
  4.  
  5. start
  6.     declare
  7.         num choiceNum //Options 1 to 3
  8.         num userISBN //User input ISBN
  9.         string userTitle //User input title
  10.         num arrayISBN[] //Array of ISBN's from file
  11.         string arrayTitle[] //Array of title's from file
  12.         char arrayAvail[] //Array of availability
  13.         num highCard = 9999 //Highest card number
  14.         num lowCard = 1000 //Lowest card number
  15.         num cardNum //User's card number
  16.         num posValue //Position of ISBN/Title in an array
  17.         num fileLength //Length of file
  18.     fileArray(arrayISBN, arrayTitle, arrayAvail, fileLength)
  19.     do
  20.         cardNum = getCardNumber(lowCard, highCard, cardNum)
  21.         output "What would  you like to search by (1 = ISBN, 2 = Title, 3 = Quit)?: "
  22.         input choiceNum
  23.         if choiceNum == 1
  24.             lookUpTitle(userISBN, arrayISBN, posArray, fileLength)
  25.             output "The title of the book is: " arrayTitle[i]
  26.         endIf
  27.         if choiceNum == 2
  28.             lookUpISBN(userTitle, arrayTitle, posArray, fileLength)
  29.             output "The ISBN of the book is: " arrayISBN[i]
  30.         endIf
  31.     while !(choiceNum == 3)
  32.  
  33. void fileArray (num arrayISBN, num arrayTitle, num arrayAvail, num& fileLength)
  34.     ifstream fin
  35.     while (!fin.eof())
  36.         fin arrayISBN[i]
  37.         fin arrayTitle[i]
  38.         fin arrayAvail[i]
  39.         i = i + 1
  40.         fileLength = i
  41.     endWhile
  42. return
  43.  
  44. num getCardNumber(num& lowCard, num& highCard, num& cardNum)
  45.     do
  46.         output "Please enter your card number: "
  47.         input cardNum
  48.     while cardNum >= highCard AND cardNum <= lowCard
  49. return cardNum
  50.  
  51. lookUpTitle (mum& userISBN, num arrayISBN, num& posArray, num& fileLength)
  52.     for int i = 0, i < fileLength, i step 1
  53.         if userISBN == arrayISBN[i]
  54.             posArray = i
  55.         endIF
  56.     endFor
  57. return posArray
  58.        
  59. lookUpISBN (mum& userTitle, string arrayTitle, num& posArray, num& fileLength)
  60.     for int i = 0, i < fileLength, i step 1
  61.         if userTitle == arrayTitle[i]
  62.             posArray = i
  63.         endIF
  64.     endFor
  65. return posArray
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. #include<fstream>
  76. #include<iostream>
  77. #include<string>
  78. using namespace std;
  79.  
  80. const int DB_SIZE = 15;
  81. int copyBookInfo(ifstream&);
  82. string bookInfo(
  83.  
  84.  
  85.  
  86.  
  87.  
  88. int copyBookInfo(ifstream& in)
  89. {
  90.     int isbn;
  91.     string title, author;
  92.     char avail;
  93.    
  94.     in >> isbn;
  95.     cout << "ISBN: " << isbn << endl;
  96.     in.ignore(1, '\t');
  97.     getline(in, title, '/t');
  98.     cout << "Title: " << title << endl;
  99.  
  100.     getline(in, author, '/t');
  101.    
  102.     cout << "Author: " << author << endl;
  103.  
  104.     in >> isbn;
  105.     cout << "ISBN: " << isbn << endl;
  106.     in.igore(1, '/t');
  107.     getline(in, title, '/t');
  108.     cout << "Title: " << title << endl;
  109.    
  110.     getline(in, author, '/t');
  111.  
  112.     cout << "Author: " << author << endl;
  113.     in >> avail;
  114.     cout << "Available: " << avail < endl;
Add Comment
Please, Sign In to add comment