Mini-book Management system for Java Small project

Source: Internet
Author: User

 PackageMini book management system;ImportJava.util.Scanner; Public classBookmgr { Public Static voidMain (string[] args) {Scanner input=NewScanner (system.in); //Data Initialization 6 books//Book: Name of book, Book loan status, book borrowing date, number of books borrowedString[]names =NewString[6]; int[]states =New int[6];//0 available, 1 loaned        int[]dates =New int[6]; int[] counts =New int[6]; names[0] = "Snow White"; dates[0] = 5; states[0] = 1; counts[0] = 10; names[1] = "Gourd Brothers"; dates[1] = 0; states[1] = 0; counts[1] = 16; names[2] = "Snow White 2"; dates[2] = 0; states[2] = 0; counts[2] = 78; //whether the user exits the system true means not exiting, false means exiting the system.         BooleanFlag =true; intnum = 0;  Do{System.out.println ("******** Welcome to the mini-book Management system ********"); System.out.println ("1. View Books"); System.out.println ("2. New Books"); System.out.println ("3. Borrowing books"); System.out.println ("4. Return the book"); System.out.println ("5. Delete a book"); System.out.println ("6. Exit the System"); System.out.print ("Please select your action:"); intChoose =Input.nextint (); Switch(choose) { Case1:                //View BooksSystem.out.println ("\ n book Information list--"); System.out.println ("Book number \ t book name \ t book status \ t borrowing date \ t borrowing times"); //Loop through all the books                 for(inti = 0;i<names.length;i++) {                    if(Names[i]! =NULL) {String State= (States[i] = = 0)? " Available to borrow ":" Lent "; String Date= (Dates[i] = = 0)? "":d ates[i]+ "Day"; String Count= counts[i]+ "Times"; System.out.println ((i+1) + "\ T" +names[i]+ "\ T" +state+ "\ T" +date+ "\ T" +count); }Else{                        //The name of the first null book is encountered, meaning that the book behind it is also null and does not have to be looped.                         Break; }                }                 Break;  Case2:                //New BooksSystem.out.println ("\ n book Information list--"); System.out.print ("Please enter new book name:"); String name=Input.next (); //If you can add a new book, if the Shelf is full (6), you will be able to add true to False.                                BooleanFlagadd =false;  for(inti = 0;i<names.length;i++) {                    if(Names[i] = =NULL) {Flagadd=true; Names[i]=name; System.out.println ("Book" "+name+" added success! ");  Break; }                }                if(!Flagadd) {System.out.println ("Sorry, the shelves are full, unable to add books!" "); }                 Break;  Case3:                //Borrowing Books                 Break;  Case4:                //Return Books                 Break;  Case5:                //Delete a book                 Break;  Case6:                //Exit SystemFlag =false;  Break; default:                //Enter the wrong numberFlag =false;  Break; }            //if flag== false, end the loop and jump out of the system            if(Flag = =false) {                //Jump out of the loop                 Break; }Else{                //the user does not end the use of the system, on behalf of the user wants to return to the main menuSystem.out.println ("Please enter 0 to return"); Num=Input.nextint (); }        } while(num = = 0); System.out.println ("Thank you, welcome to use!" "); }    }

Mini-book Management system for Java Small project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.