0% found this document useful (0 votes)
4 views6 pages

Java Student and Library Management

The document contains Java code for two applications: a student management system and a library management system. The student system allows input of student details and calculates their average marks to determine pass or fail status, while the library system manages book details, issuing, and returning books. Both applications include classes with methods for handling their respective functionalities.

Uploaded by

Thor Odin
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 views6 pages

Java Student and Library Management

The document contains Java code for two applications: a student management system and a library management system. The student system allows input of student details and calculates their average marks to determine pass or fail status, while the library system manages book details, issuing, and returning books. Both applications include classes with methods for handling their respective functionalities.

Uploaded by

Thor Odin
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

Ansari Raza , INFT - B , 56

( 1 ) CODE A : [Link]​

package university;

public class Student {


private int rollNo;
private String name;
private int[] marks;

public Student(int rollNo, String name, int[] marks) {


[Link] = rollNo;
[Link] = name;
[Link] = marks;
}

public double calculateAverage() {


int sum = 0;
for (int mark : marks) {
sum += mark;
}
return (double) sum / [Link];
}

public void displayResult() {


double avg = calculateAverage();
[Link]("Student: " + name + " (Roll No: " + rollNo + ")");
[Link]("Average Marks: " + avg);
if (avg >= 28) {
[Link]("Status: PASS");
} else {
[Link]("Status: FAIL");
}
Ansari Raza , INFT - B , 56

[Link]("-------------------------");
}
}​

CODE B : [Link]​

import [Link];
import [Link];

public class TestStudents {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);

[Link]("Enter number of students: ");


int n = [Link]();

for (int i = 0; i < n; i++) {


[Link]("\nEnter details for student " + (i + 1));
[Link]("Roll No: ");
int rollNo = [Link]();
[Link]();
[Link]("Name: ");
String name = [Link]();

[Link]("Enter number of subjects: ");


int subjects = [Link]();
int[] marks = new int[subjects];

for (int j = 0; j < subjects; j++) {


[Link]("Mark for subject " + (j + 1) + ": ");
marks[j] = [Link]();
}

Student s = new Student(rollNo, name, marks);


Ansari Raza , INFT - B , 56

[Link]();​
}
[Link]();
}
}​

O U T P U T :​


Ansari Raza , INFT - B , 56

( 2 ) C O D E A : [Link]​

package library;

public class Book {


int bookId;
String title;
String author;
boolean isAvailable;

public Book(int bookId, String title, String author) {


[Link] = bookId;
[Link] = title;
[Link] = author;
[Link] = true;
}
public void issueBook() {
if (isAvailable) {
isAvailable = false;
[Link](title + " has been issued.");
} else {
[Link](title + " is not available.");
}
}
public void returnBook() {
if (!isAvailable) {
isAvailable = true;
[Link](title + " has been returned.");
} else {
[Link](title + " was not issued.");
} }

public void displayDetails() {


[Link]("Book ID: " + bookId);
[Link]("Title: " + title);
Ansari Raza , INFT - B , 56

[Link]("Author: " + author);


[Link]("Availability: " + (isAvailable ? "Available" : "Issued"));
[Link]("----------------------------------");
} }​

CODE B : [Link]​

import [Link];

public class LibraryTest {


public static void main(String[] args) {
Book b1 = new Book(101, "Java Programming", "Shani Ambarnath");
Book b2 = new Book(102, "Data Structures", "Jaans Legend");
Book b3 = new Book(103, "Operating Systems", "Abhishekh Waghmare");

[Link]("=== Book Details ===");


[Link]();
[Link]();
[Link]();

[Link]("=== Issue Books ===");


[Link]();
[Link]();
[Link]();

[Link]("=== Return Books ===");


[Link]();
[Link]();

[Link]("=== Final Status ===");


[Link]();
[Link]();
[Link]();
}
}
Ansari Raza , INFT - B , 56


O U T P U T :​

You might also like