0% found this document useful (0 votes)
64 views

Project On Library System

The document defines a Book class with fields to store a book's name, author, price, quantity in stock, and publication date. Getter and setter methods are included for each field. A Book array is initialized with sample Book objects. A menu is displayed to allow viewing book details, updating stock quantities, removing stock, and adding new books. User input is gathered to perform the selected operation on the Book objects in the array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Project On Library System

The document defines a Book class with fields to store a book's name, author, price, quantity in stock, and publication date. Getter and setter methods are included for each field. A Book array is initialized with sample Book objects. A menu is displayed to allow viewing book details, updating stock quantities, removing stock, and adding new books. User input is gathered to perform the selected operation on the Book objects in the array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Project on Library System

package BOOk;

public class Book {

private String name;

private String author;

private double price;

private int store;

private String publishDate;

public Book(String name, String author, double price, int store, String
publishDate) {

this.name = name;

this.author = author;

this.price = price;

this.store = store;

this.publishDate = publishDate;

}
public Book() {

super();

// TODO Auto-generated constructor stub

public String getName() {

return name;

public void setName(String name) {

this.name = name;

public String getAuthor() {

return author;

public void setAuthor(String author) {

this.author = author;

public double getPrice() {

return price;

}
public void setPrice(double price) {

this.price = price;

public int getStore() {

return store;

public void setStore(int store) {

this.store = store;

public String getPublishDate() {

return publishDate;

public void setPublishDate(String publishDate) {

this.publishDate = publishDate;

public void add(){

}
package BOOk;

import java.util.Scanner;

public class newBook {

public static void main(String[] args) {

System.out.println("Welcome to the Bookstore");

System.out.println("Please enter username:");

Scanner input = new Scanner(System.in);

String userName = input.nextLine();

String trueUserNamer = "admin";

System.out.println("Please enter password:");

String mima = input.nextLine();

String password = "admin";

if ((userName.equals(trueUserNamer)) && (mima.equals(password)))

System.out.println("Login Success");

else

System.out.println("Login failed");

Book[] book = new Book[5];


Book b1 = new Book ("Ghost Blowing Light", "World Singer", 33,
6, "2004-2-12");

Book b2 = new Book ("Devil World", "Morse", 45, 4, "2001-1-1");

Book b3 = new Book ("Time Machine", "Will", 64, 5, "2000-1-22");

Book b4 = new Book("Harry Potter", " ", 12, 3, "1998-4-12");

Book b5 = new Book("No", "No", 0, 0, "No");

book[0] = b1;

book[1] = b2;

book[2] = b3;

book[3] = b4;

book[4] =b5;

do {

System.out.println("~~~~~~~~ Welcome to the library


management system~~~~~~~~");

System.out.println("\t1.View Books");

System.out.println("\t2.Books in the library");

System.out.println("\t3.Book Outbound");

System.out.println("\t4.Add a book");

System.out.println("\t5.exit");
System.out.println("Please do your operation");

int num = input.nextInt();

switch (num) {

Case 1:// query

System.out.println("title\t author\t price\t


inventory\t publication date");

for (int i = 0; i < book.length; i++) {

Book b = book[i];

System.out.println(b.getName() + "\t" +
b.getAuthor() + "\t" + b.getPrice() + "\t" + b.getStore()

+ "\t" +
b.getPublishDate());

break;

case 2:

// Book storage;

System.out.println("Please enter the title");


String name = input.next();

If (name.equals(" ") || name.endsWith(" ") ||


name.endsWith("Harry Potter") || name.endsWith("Time Machine"))

System.out.println("Please enter to
increase inventory");

int store = input.nextInt();

for (int i = 0; i <= book.length; i++) {

if (name.equals(book[i].getName())) {

book[i].setStore(book[i].getStore() + store);

break;

break;

Case 3:// out of the library

System.out.println("Please enter the title");

String name1 = input.next();

If (name1.equals(" ") || name1.endsWith(" ") ||


name1.endsWith("Harry Potter") || name1.endsWith("Time Machine"))

System.out.println("Please enter the


quantity to borrow");
int store1 = input.nextInt();

for (int i = 0; i <= book.length; i++) {

if (name1.equals(book[i].getName())) {

book[i].setStore(book[i].getStore() - store1);

break;

break;

case 4:

System.out.println("Please enter the title");

String name2=input.next();

System.out.println("Please enter the author");

String author2=input.next();

System.out.println("Please enter the price");

double price2=input.nextDouble();

System.out.println("Please enter the stock");

int store2=input.nextInt();
System.out.println("Please enter the publication
date");

String publicDate=input.next();

b5.setName(name2);b5.setAuthor(author2);b5.setPrice(price2);b5.setStore(store2);

b5.setPublishDate(publicDate);

break;

case 5:

return;

} while (true);

output of the program

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy