Advertisement
Guest User

nfewfile.cxx

a guest
Aug 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.54 KB | None | 0 0
  1. #include <iostream>
  2. #include"main.h"
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <time.h>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  
  12. int main(int argc, char** argv) {
  13.    
  14. int outerChoice = 0;
  15. while(outerChoice!=9){
  16.     system("cls");
  17.     cout<<"\n Library Management Version 1.0 \n";
  18.     cout<<"\n1. Amin";
  19.     cout<<"\n2. User";
  20.     cout<<"\n9. Exit";
  21.     cout<<"\n\nEnter your choice : ";
  22.     cin>>outerChoice;
  23.    
  24.     if( outerChoice == 1 )
  25.     {
  26.     char adminUser[10];
  27.     char adminPassword[10];
  28.    
  29.     system("cls");
  30.     cout<<"\n ---------- Admin Login -------";
  31.     cout<<"\n\n Enter username: ";
  32.     cin>>adminUser;
  33.     cout<<"\n Enter password:";
  34.     cin>>adminPassword;
  35.     if( (strcmp(adminUser, adminUser) == 0) &&
  36.         ( strcmp(adminPassword, adminPassword) == 0)){
  37.        
  38.     getchar(); getchar();
  39.     system("cls");
  40.     int innerChoice = 0;
  41.     while(innerChoice != 9){
  42.     cout<<"\n\n Admin Login is Successful !! Press any key to continue.."; 
  43.     cout<<"\n1. Add Book";
  44.     cout<<"\n2. Update Book";
  45.     cout<<"\n3. Delete Book";
  46.     cout<<"\n4. List of All Books";
  47.     cout<<"\n9. Exit";
  48.     cout<<"\n\n Enter your choice : ";
  49.     cin>>innerChoice;
  50.         switch(innerChoice){
  51.            
  52.         case 1: Add Book() ; break;
  53.         case 2: Update Book(); break;
  54.         case 3: Delete Book(); break;
  55.         case 4: List Of All Books(); break;
  56.         default: cout<<"\n\n Invalid Choice. Press any key to continue..";
  57.                  getchar();
  58.     }
  59.     system("cls");
  60.     }
  61.                    
  62.     }
  63.     else
  64.     {
  65.     cout<<"\n\n Error : Invalid Credentials. Press any key to conitnue";
  66.     getchar();
  67.     }
  68.                    
  69.     }
  70.     else if(outerChoice ==2) {             
  71.         char studentUser[10];
  72.         char studentPassword[10];
  73.            
  74.         system("cls");
  75.         cout<<"\n ---------- Student Login -------";
  76.         cout<<"\n\n Enter username: ";
  77.         cin>>studentUser;
  78.         cout<<"\n Enter password:";
  79.         cin>>studentPassword;
  80.            
  81.         if( (strcmp(studentUser, USER) ==0)  &&
  82.             (strcmp(studentPassword, studentPassword) == 0)){
  83.         int innerChoice = 0;
  84.         while(innerChoice != 9){
  85.         system("cls");
  86.             cout<<"\n1. Borrow a Book";
  87.             cout<<"\n2. Return a Book";
  88.             cout<<"\n3. List of All Books";
  89.             cout<<"\n9. Exit";  
  90.         cout<<"\n\n Enter your choice : ";
  91.         cin>>innerChoice;  
  92.        
  93.         switch(innerChoice){
  94.         case 1: Borrow a Book();break;
  95.         case 2: Return a Book();break;
  96.         case 3: List Of All Books(); break;
  97.         case 9: break;
  98.         default: cout<<"\n\n Error: Invalid Choice. Press any key to continue..";
  99.                 getchar();getchar();
  100.            
  101.         }
  102.                
  103.         }
  104.         system("cls");
  105.         }
  106.         else
  107.         {
  108.         cout<<"\n\n Error : Invalid Credentials. Press any key to conitnue";
  109.         getchar();getchar();
  110.            
  111.         }
  112.     }
  113.     else if(outerChoice!=9){
  114.         cout<<"\n\n Invalid choice. Press any key to continue..";
  115.         getchar();getchar();
  116.     }
  117.     else
  118.     {
  119.         cout<<"\n\n Thank you for using it !! Press any key to exit";
  120.         getchar();getchar();
  121.     }
  122. }
  123.  
  124. return 0;
  125. }
  126.  
  127. int Add (a Book) {
  128. int bookid;
  129. char Book name[20];
  130. char Book author[20];
  131. int year, month, day;
  132.  
  133. time_t t = time(NULL);
  134. struct tm tm = *localtime(&t);
  135.  
  136. year = tm.tm_year + 1900;
  137. month = tm.tm_mon +1;
  138. day = tm.tm_mday;
  139.  
  140.  
  141. system("cls");
  142. cout<<"\n ---- Add a new Book ----";
  143.  
  144. cout<<"\n\n Enter 4 digit numberic id :";
  145. cin>>bookid;
  146. cout<<"\n Enter book name : ";
  147. cin>>bookname;
  148. cout<<"\n Enter book author : ";
  149. cin>>bookauthor;
  150.  
  151. char filename[20];
  152.  
  153. sprintf(filename,"%d%s",bookid,".dat");
  154.  
  155. ofstream file(filename);
  156.  
  157. file<<bookname<<"\n";
  158. file<<bookauthor<<"\n";
  159. file<<year<<"\n";
  160. file<<month<<"\n";
  161. file<<day<<"\n";
  162.  
  163. file.close();
  164.  
  165. cout<<"\n File Saved Successfully !!";
  166. getchar(); getchar();  
  167. }
  168.  
  169. int deleteBook(){
  170.    
  171.    
  172. }
  173.  
  174. int updateBook(){
  175.    
  176.    
  177. }
  178.  
  179. int listOfAllBooks(){
  180.    
  181.    
  182. }
  183.  
  184. int borrowBook(){
  185.    
  186.    
  187. }
  188.  
  189. int returnBook(){
  190.    
  191. }
  192. int adminLogin(){
  193.    
  194.    
  195. }
  196.  
  197. int userLogin(){
  198.  
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement