Answer to Question #249477 in Java | JSP | JSF for Locos

Question #249477

Write a program to implement the Library Information System using

packages with the following instructions

a) Create a Books class in pkg1.

b) Create an Admin class in pkg2.

c) Create a User class in pkg3.

d) Import all packages in Test class and do the following operations in a menu-driven

fashion. Add books, Search books, and List books.


1
Expert's answer
2021-10-11T00:05:28-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Books b1=new Books();
		int c;
		System.out.println("Choose an operation to perform:\n1. Add book\n2. Search book\n3. List books");
		Scanner input=new Scanner(System.in);
		c=input.nextInt();
		if(c==1){
		    b1.addBook(123, "ABCD");
		}
		else if(c==2){
		    b1.Searchbooks(123);
		}
		else if(c==3){
		    b1.Listbooks();
		}
	}
}
class Books{
    private int book_id;
    private String book_name;
    public void setBookId(int id){
        book_id=id;
    }
    public int getBookId(){
        return book_id;
    }
    public void setBookName(String n){
        book_name=n;
    }
    public String getBookName(){
        return book_name;
    }
    public void addBook(int id,String name){
        System.out.println("A new book added:\nName: "+name+"\nBook id: "+id);
    }
    public void Searchbooks(int id){
        System.out.println("Books number "+id+" is available");
    }
    public void Listbooks(){
        System.out.println("Name: "+getBookName()+"\nBook id: "+getBookId());
    }
}
class Admin{
    private String name;
    public void setName(String n){
        name=n;
    }
    public String getName(){
        return name;
    }
}
class User{
    private String name;
    private int user_id;
    public void setName(String n){
        name=n;
    }
    public String getName(){
        return name;
    }
    public void setUserId(int id){
        user_id=id;
    }
    public int getUserId(){
        return user_id;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS