Project-1
Develop an application to manage Student information, including
enrolment, grades, and attendance.
To set and get rollno, name and branch
To calculate percentage of 5 subjects.
To display complete data of a student
Implementation Code:
class Student {
int rollNo;
String name;
String branch;
int[] marks = new int[5]; // 5 subjects
// set data
void setData(int r, String n, String b, int[] m) {
rollNo = r;
name = n;
branch = b;
for (int i = 0; i < 5; i++) {
marks[i] = m[i];
// calculate percentage
double getPercentage() {
int total = 0;
for (int i = 0; i < 5; i++) {
total += marks[i];
return total / 5.0;
// display data
void display() {
System.out.println("Roll No: " + rollNo);
System.out.println("Name: " + name);
System.out.println("Branch: " + branch);
System.out.print("Marks: ");
for (int i = 0; i < 5; i++) {
System.out.print(marks[i] + " ");
System.out.println("\nPercentage: " + getPercentage() +
"%");
public class StudentApp {
public static void main(String[] args) {
Student s1 = new Student();
// static data
int[] marks = {80, 75, 90, 85, 70};
s1.setData(101, "Rahul Sharma", "CSE", marks);
s1.display();
Project-2
Develop a system to manage an inventory of products with below
given specifications.
To set and get productid, name, quantity, price
Search by productid
Code:
class Product {
int productId;
String name;
int quantity;
double price;
// set data
void setData(int id, String n, int q, double p) {
productId = id;
name = n;
quantity = q;
price = p;
// display data
void display() {
System.out.println("Product ID: " + productId);
System.out.println("Name: " + name);
System.out.println("Quantity: " + quantity);
System.out.println("Price: " + price);
public class InventorySystem {
public static void main(String[] args) {
// create products
Product p1 = new Product();
Product p2 = new Product();
// static data
p1.setData(101, "Laptop", 5, 55000.0);
p2.setData(102, "Mouse", 20, 500.0);
// search by productId
int searchId = 102; // you can change this value to test
if (p1.productId == searchId) {
p1.display();
} else if (p2.productId == searchId) {
p2.display();
} else {
System.out.println("Product not found!");
Project-3
Develop a system to manage a library of books with below given
specifications.
To set and get bookid, name, author, quantity, price
Search by bookid
To list all books
Code:
class Book {
int bookId;
String name;
String author;
int quantity;
double price;
// set data
void setData(int id, String n, String a, int q, double p) {
bookId = id;
name = n;
author = a;
quantity = q;
price = p;
// display book details
void display() {
System.out.println("Book ID: " + bookId);
System.out.println("Name: " + name);
System.out.println("Author: " + author);
System.out.println("Quantity: " + quantity);
System.out.println("Price: " + price);
System.out.println("--------------------");
}
// search by bookId
boolean searchById(int id) {
if (bookId == id) {
display();
return true;
return false;
public class LibraryApp {
public static void main(String[] args) {
// create some books
Book b1 = new Book();
b1.setData(301, "Java Programming", "James Gosling", 5,
550.0);
Book b2 = new Book();
b2.setData(302, "Python Basics", "Guido van Rossum", 8,
450.0);
Book b3 = new Book();
b3.setData(303, "C++ Guide", "Bjarne Stroustrup", 4, 600.0);
// ✅ List all books
System.out.println("📚 Listing All Books:");
b1.display();
b2.display();
b3.display();
// ✅ Search by Book ID
System.out.println("🔎 Searching for Book ID 302:");
if (!(b1.searchById(302) || b2.searchById(302) ||
b3.searchById(302))) {
System.out.println("Book not found!");
System.out.println("🔎 Searching for Book ID 310:");
if (!(b1.searchById(310) || b2.searchById(310) ||
b3.searchById(310))) {
System.out.println("Book not found!");