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

JAVA_exp (1)

The document outlines an experiment for a library management system using Java, performed by a student named Ishan. It details the aim and objective of the project, which includes operations like borrowing, returning, and checking book availability. The provided Java code implements these functionalities through a simple console application.

Uploaded by

Rohit Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

JAVA_exp (1)

The document outlines an experiment for a library management system using Java, performed by a student named Ishan. It details the aim and objective of the project, which includes operations like borrowing, returning, and checking book availability. The provided Java code implements these functionalities through a simple console application.

Uploaded by

Rohit Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 1.1
Student Name: Ishan UID: 23BCS12656
Branch: BE-CSE Section/Group: 605-A
Semester: 4th Date of Performance: 18-01-25
Subject Name: OOPS using JAVA Subject Code: 23CSP-202

1. Aim: To create a simple library management system where users


can perform basic operations on a book, such as borrowing it,
returning it, and checking its availability.

2. Objective: To implement a basic library system that manages


book availability through borrowing, returning, and checking
status operations.

3. Java Code:

import java.util.Scanner;
class Book1 {
private String title;
private boolean isAvailable;

public Book1(String title) {


this.title = title;
this.isAvailable = true;
}

public String getTitle() {


return title;
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

public boolean isAvailable() {


return isAvailable;
}

public void borrowBook1() {


if (isAvailable) {
isAvailable = false;
System.out.println(title + " has been borrowed.");
} else {
System.out.println(title + " is not available.");
}
}

public void returnBook1() {


isAvailable = true;
System.out.println(title + " has been returned.");
}

public void checkAvailability() {


if (isAvailable) {
System.out.println(title + " is available.");
} else {
System.out.println(title + " is not available.");
}
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

public class simpleLibrary {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Enter the title of the book1:");


String title = scanner.nextLine();

Book1 book1 = new Book1(title);

System.out.println("Enter 1 to borrow the book1, 2 to return


the book1, 3 to check availability:");
int action = scanner.nextInt();

if (action == 1) {
book1.borrowBook1();
} else if (action == 2) {
book1.returnBook1();
} else if (action == 3) {
book1.checkAvailability();
} else {
System.out.println("Invalid option.");
}

scanner.close();
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

4. Output:

You might also like