fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <array>
  4. #include <limits>
  5.  
  6. using namespace std;
  7.  
  8. class book
  9. {
  10. std::string bookname;
  11. std::string isbn;
  12. std::string author;
  13. std::string category;
  14. float price;
  15. int noc;
  16.  
  17. public:
  18. const std::string& getBookname() const { return bookname; }
  19. const std::string& getISBN() const { return isbn; }
  20. const std::string& getAuthor() const { return author; }
  21. const std::string& getCategory() const { return category; }
  22. float getPrice() const { return price; }
  23. float getNoC() const { return noc; }
  24.  
  25. void accept()
  26. {
  27. cout<<"Enter book name :- \n";
  28. std::getline(std::cin, bookname);
  29. cout<<"Enter isbn no of the book:- \n";
  30. std::getline(std::cin, isbn);
  31. cout<<"Enter authour name:- \n";
  32. std::getline(std::cin, author);
  33. cout<<"Enter category of book:- \n";
  34. std::getline(std::cin, category);
  35. cout<<"Enter price of the book :- \n";
  36. std::cin>>price;
  37. cout<<"Enter no of copies of book available in the library :- \n";
  38. std::cin>>noc;
  39. std::cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
  40. }
  41.  
  42. void display()
  43. {
  44. std::cout<<bookname<<std::endl;
  45. std::cout<<isbn<<std::endl;
  46. std::cout<<author<<std::endl;
  47. std::cout<<category<<std::endl;
  48. std::cout<<price<<std::endl;
  49. std::cout<<noc<<std::endl;
  50. }
  51.  
  52. void issue()
  53. {
  54. }
  55. };
  56.  
  57. int main()
  58. {
  59. std::array<book, 5> b;
  60. for(int i=0;i<b.size();++i)
  61. {
  62. b[i].accept();
  63. }
  64.  
  65. std::string booksearch;
  66. std::cout<<"Enter name of book member wants to issue :- \n";
  67. std::getline(cin, booksearch);
  68. std::cout<<"Searching for: " << booksearch << "\n";
  69. for(int i=0;i<b.size();++i)
  70. {
  71. if (b[i].getBookname() == booksearch)
  72. {
  73. b[i].display();
  74. b[i].issue();
  75. break;
  76. }
  77. }
  78.  
  79. std::string dummy;
  80. std::cout << "Hit return:";
  81. std::getline(std::cin, dummy);
  82.  
  83. return 0;
  84. }
Success #stdin #stdout 0s 3420KB
stdin
First Book
10001
Author One
Programming
49.99
1
Book the Second
10002
Second Author
Windows
99.99
2
Book Number Three
10003
Author J Three
Holidays
29.99
1
Book Four
10004
Fourth R. Author
Swimming
39.59
2
Fifth Book
10005
James Bond
Being a Spy
00.7
1
Book Number Three
Book Number Three
stdout
Enter book name :- 
Enter isbn no of the book:- 
Enter authour name:- 
Enter category of book:- 
Enter price of the book :- 
Enter no of copies of book available in the library :- 
Enter book name :- 
Enter isbn no of the book:- 
Enter authour name:- 
Enter category of book:- 
Enter price of the book :- 
Enter no of copies of book available in the library :- 
Enter book name :- 
Enter isbn no of the book:- 
Enter authour name:- 
Enter category of book:- 
Enter price of the book :- 
Enter no of copies of book available in the library :- 
Enter book name :- 
Enter isbn no of the book:- 
Enter authour name:- 
Enter category of book:- 
Enter price of the book :- 
Enter no of copies of book available in the library :- 
Enter book name :- 
Enter isbn no of the book:- 
Enter authour name:- 
Enter category of book:- 
Enter price of the book :- 
Enter no of copies of book available in the library :- 
Enter name of book member wants to issue :- 
Searching for: Book Number Three
Book Number Three
10003
Author J Three
Holidays
29.99
1
Hit return: