Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.16 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class project_lamia {
  4.  
  5.       /**
  6.       * @param args
  7.       */
  8.       public static void main(String[] args) {
  9.             // TODO Auto-generated method stub
  10.             int option;
  11.             String bname;
  12.             String b1="book1";
  13.             String b2="book2";
  14.             String b3="book3";
  15.             String b4="book4";
  16.             String b5="book5";
  17.             String b6="book6";
  18.            
  19.             String user="lamya";
  20.             String ID;
  21.             String pass="123456";
  22.             int passw=123456;
  23.             char gh='r';
  24.  
  25. do
  26.             //while(gh!='0')
  27.             {
  28.                         System.out.println("HELLOW, you are welcome to the online-book store:");
  29.                         System.out.println("Enter the number beside each option to proceed:");
  30.                        
  31.                         System.out.println(" 1:  See the list of new books\n 2: Borrow a Books\n 3: Return a Books\n 4: Show Details about the Books \n 5: Administrator only \n 0: To exit the program");
  32.                         option=TextIO.getInt();
  33.                        
  34.                                                
  35.                        
  36.                         if (option==1)
  37.                         {
  38.                         System.out.println("SEE THE LIST OF NEW BOOKS:");
  39.                         System.out.println("Books in Store are:");
  40.                         System.out.println(" •  Book 1\n •  Book 2\n •  Book 3\n •  Book 4\n •     Book 5\n •  Book 6");
  41.                         }
  42.                                          
  43.                              
  44.                         else if (option==2)
  45.                         {
  46.                              
  47.                         //System.out.println("BORROW A BOOK:");
  48.                         System.out.println("Enter book name:");
  49.                         bname=TextIO.getlnString();
  50.                        
  51.                               if (bname.contentEquals(b1)|| bname.contentEquals(b2)||bname.contentEquals(b3)||bname.contentEquals(b4)||bname.contentEquals(b5)||bname.contentEquals(b6))
  52.                              
  53.                                     System.out.println("The book is available enter 'p' to process ");
  54.                              
  55.                               else
  56.                              
  57.                               System.out.println("Sorry but the book is not available ");
  58.                              
  59.                         }  
  60.                        
  61.                              
  62.                                    
  63.                              
  64.                                    
  65.                         else if (option==3)
  66.                         {
  67.                         System.out.println("RETURN A BOOK");
  68.                       System.out.println("Enter book name:");
  69.                       bname=TextIO.getlnString();
  70.                       System.out.println("Enter user name:");
  71.                       user=TextIO.getlnString();
  72.                       System.out.println("Enter ID number:");
  73.                       ID=TextIO.getlnString();
  74.                       System.out.println("Thanks and do come again!");
  75.                         }
  76.                        
  77.                                                                              
  78.                                          
  79.                         else if (option==4)
  80.                         {
  81.                         System.out.println("SHOW DETAILS ABOUT THE BOOK");
  82.                        
  83.                         System.out.println("Enter Book Name:");
  84.                         bname=TextIO.getlnString();
  85.                        
  86.                               if (bname.contentEquals("book1"))
  87.                               {
  88.                               System.out.print("book 1 is a book about ..... the author is ..");
  89.                               }
  90.                               else if (bname.contentEquals("book2"))
  91.                               {
  92.                               System.out.print("book 2 is a book about ..... the author is ..");
  93.                               }
  94.                               else if (bname.contentEquals("book3"))
  95.                               {
  96.                               System.out.print("book 3 is a book about ..... the author is ..");
  97.                               }
  98.                               else if (bname.contentEquals("book4"))
  99.                               {
  100.                               System.out.print("book 4 is a book about ..... the author is ..");
  101.                               }
  102.                               else if (bname.contentEquals("book5"))
  103.                               {
  104.                               System.out.print("book 5 is a book about ..... the author is ..");
  105.                               }
  106.                               else if (bname.contentEquals("book6"))
  107.                               {
  108.                               System.out.print("book 6 is a book about ..... the author is ..");
  109.                               }
  110.                               else
  111.                               {
  112.                                     System.out.print("this book is bot available in the store");
  113.                               }
  114.                         }
  115.                         // Title, Author1, Author2, Publisher, ISBN, Edition and
  116.                         // Publication date
  117.                        
  118.                        
  119.                        
  120.                        
  121.                        
  122.                        
  123.                         else if (option==5)
  124.                         {
  125.                         System.out.println("ADMINISTRATOR ONLY (check details of the Book Store)");
  126.                         System.out.println("enter you user name:");
  127.                         user=TextIO.getlnString();
  128.                        
  129.                         System.out.println("enter password:");
  130.                         passw=TextIO.getInt();
  131.                         //pass=TextIO.getlnString();
  132.                         if ((user.contentEquals("lamya")&& passw==123456))
  133.                        
  134.                               //if ((user.contentEquals("lamya")&& pass.contentEquals("123456"))|(user.contentEquals("noura")&&pass.contentEquals("09876"))|(user.contentEquals("lama")&&pass.contentEquals("13579")))
  135.                               {
  136.                               System.out.println("this is a list if borrowed books:\n book1\n book2\n book5");
  137.                               System.out.println("the books that are available :\n book3\n book4 ");
  138.                               System.out.print("this is a list of the users:  lamya\n  noura\n  lama");
  139.                               }
  140.                               else
  141.                                     System.out.print("you do not have a valid account ");
  142.                         }
  143.  
  144.                        
  145.                        
  146.                       else
  147.                         System.out.println("You did not enter the valid choice");
  148.  
  149.                       //System.exit(0);
  150.                         //gh++;
  151.                         System.out.println("To go back press 'G', To exit press '0'");
  152.                         gh=TextIO.getChar();
  153.                              
  154.             }
  155.       while (gh!='e');
  156.  
  157.              }
  158.  
  159.      
  160.  
  161.  
  162.  }
  163.  
  164. /**
  165.  * Class to handle standard input functionalities
  166.  */
  167. class TextIO {
  168.     /**
  169.      * static (one) instance of a bufferedreader
  170.      */
  171.     private static BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
  172.  
  173.     /**
  174.      * Reads a string from standard input
  175.      *
  176.      * @return string from standard input
  177.      */
  178.     public static String getlnString() {
  179.         try {
  180.             return br.readLine();
  181.         } catch( Exception e ) {
  182.             return "";
  183.         }
  184.     }
  185.    
  186.     /**
  187.      * Reads a char from standard input
  188.      *
  189.      * @return char from standard input
  190.      */
  191.     public static char getChar() {
  192.         return getlnString().charAt(0);
  193.     }
  194.  
  195.     /**
  196.      * Reads a integer from standard input
  197.      *
  198.      * @return int from standard input
  199.      */
  200.     public static int getInt() {
  201.         while( true )
  202.             try {
  203.                 return Integer.parseInt( getlnString() );
  204.             } catch( Exception e ) {
  205.                 // return 0;
  206.             }
  207.     }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement