Name – Sumitra Sahoo
Roll No – 82
Regd. No- 2405432090
MCA 2nd Semester
1. Student Management System – Calculate Student Performance
import java.util.Scanner;
class StudentManagement {
String studentName; int
studentRollNo; double[]
studentMarks; double
totalStudentMarks; double
studentPercentage;
StudentManagement(String studentName, int studentRollNo) { this.studentName
= studentName;
this.studentRollNo = studentRollNo;
StudentManagement(String studentName, int studentRollNo, double[] studentMarks)
{ this.studentName = studentName; this.studentRollNo = studentRollNo;
this.studentMarks = studentMarks;
this.totalStudentMarks = calculateTotal(studentMarks); this.studentPercentage =
calculatePercentage(totalStudentMarks, studentMarks.length * 100);
StudentManagement(String studentName, int studentRollNo, double totalStudentMarks,
double maxStudentMarks) {
this.studentName = studentName;
this.studentRollNo = studentRollNo;
this.totalStudentMarks = totalStudentMarks;
this.studentPercentage = calculatePercentage(totalStudentMarks, maxStudentMarks);
double calculateTotal(double[] marksArray) {
double total = 0; for (double
mark : marksArray) {
total += mark;
return total;
double calculatePercentage(double total, double maxMarks) {
return (total / maxMarks) * 100;
char getGrade(double percentage) { if
(percentage >= 90) { return
'A';
} else if (percentage >= 80) { return
'B';
} else if (percentage >= 70) { return
'C';
} else if (percentage >= 60) {
return 'D'; } else { return
'F';
}
void displayDetails() {
System.out.println("\nStudent Details:");
System.out.println("Name: " + studentName);
System.out.println("Roll No: " + studentRollNo);
if (studentMarks != null) {
System.out.print("Marks: "); for (double
mark : studentMarks) {
System.out.print(mark + " ");
System.out.println();
System.out.println("Total Marks: " + totalStudentMarks);
System.out.println("Percentage: " + studentPercentage);
System.out.println("Grade: " + getGrade(studentPercentage));
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of students: "); int numStudents =
sc.nextInt(); sc.nextLine(); // Consume newline character after reading the number
of students
for (int i = 0; i < numStudents; i++) {
System.out.print("\nEnter name for student " + (i + 1) + ": ");
String name = sc.nextLine();
System.out.print("Enter roll number for student " + (i + 1) + ": ");
int rollNo = sc.nextInt();
System.out.print("Enter number of subjects: "); int
numSubjects = sc.nextInt();
double[] marks = new double[numSubjects];
System.out.println("Enter marks for " + numSubjects + " subjects:");
for (int j = 0; j < numSubjects; j++) { marks[j] = sc.nextDouble();
sc.nextLine(); // Consume newline character after reading marks
StudentManagement student = new StudentManagement(name, rollNo, marks);
student.displayDetails();
sc.close();
2. Employee Management System – Calculate Employee Salary and Benefits
import java.util.Scanner;
class Employee { String
name; int empID;
double basicSalary;
double taxRate; double
bonus; double netSalary;
Employee(String name, int empID) {
this.name = name; this.empID = empID;
Employee(String name, int empID, double basicSalary, double taxRate) {
this.name = name; this.empID = empID; this.basicSalary = basicSalary;
this.taxRate = taxRate;
Employee(String name, int empID, double basicSalary, double taxRate, double bonus) { this.name
= name;
this.empID = empID; this.basicSalary
= basicSalary; this.taxRate = taxRate;
this.bonus
= bonus;
double calculateSalary(double basicSalary, double taxRate) {
double tax = (taxRate / 100) * basicSalary; netSalary = basicSalary
- tax; return netSalary;
double calculateSalary(double basicSalary, double taxRate, double bonus) {
double tax = (taxRate / 100) * basicSalary; netSalary = basicSalary - tax +
bonus; return netSalary;
}
double calculateAnnualSalary(double monthlySalary) {
return monthlySalary * 12;
void displayEmployeeDetails() {
System.out.println("\nEmployee Details:");
System.out.println("Name: " + name);
System.out.println("Employee ID: " + empID);
System.out.println("Basic Salary: " + basicSalary);
System.out.println("Tax Rate: " + taxRate + "%");
System.out.println("Bonus: " + bonus);
System.out.println("Net Salary: " + netSalary);
System.out.println("Annual Salary: " + calculateAnnualSalary(basicSalary));
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Employee Name: ");
String name = sc.nextLine();
System.out.print("Enter Employee ID: "); int
empID = sc.nextInt();
System.out.print("Enter Basic Salary: "); double
basicSalary = sc.nextDouble();
System.out.print("Enter Tax Rate (%): "); double
taxRate = sc.nextDouble();
System.out.print("Enter Bonus (0 if no bonus): "); double
bonus = sc.nextDouble();
Employee employee;
if (bonus == 0) { employee = new Employee(name, empID,
basicSalary, taxRate); employee.calculateSalary(basicSalary,
taxRate);
} else { employee = new Employee(name, empID, basicSalary,
taxRate, bonus);
employee.calculateSalary(basicSalary, taxRate, bonus);
employee.displayEmployeeDetails();
sc.close();
3. Library Management System – Book Management
import java.util.Scanner;
class LibraryBook {
String title; String
author; int
totalCopies; int
issuedCopies;
LibraryBook(String title, String author) {
this.title = title; this.author
= author; this.totalCopies = 0;
this.issuedCopies = 0;
LibraryBook(String title, String author, int totalCopies) {
this.title = title; this.author
= author; this.totalCopies =
totalCopies; this.issuedCopies
= 0;
LibraryBook(String title, String author, int totalCopies, int issuedCopies) {
this.title = title; this.author = author; this.totalCopies = totalCopies;
this.issuedCopies = issuedCopies;
void getBookDetails(String title) {
System.out.println("Book Title: " + title);
void getBookDetails(String title, String author) {
System.out.println("Book Title: " + title + ", Author: " + author);
void getBookDetails(String title, String author, int copiesAvailable) {
System.out.println("Book Title: " + title + ", Author: " + author + ", Copies Available: " + copiesAvailable);
boolean checkAvailability(int requestedCopies) { return
(totalCopies - issuedCopies) >= requestedCopies;
void issueBook(int requestedCopies) { if
(checkAvailability(requestedCopies)) {
issuedCopies += requestedCopies;
System.out.println(requestedCopies + " copy(s)
issued.");
} else {
System.out.println("Not enough copies available.");
void returnBook(int returnedCopies) { if
(issuedCopies >= returnedCopies) {
issuedCopies -= returnedCopies;
System.out.println(returnedCopies + " copy(s) returned.");
} else {
System.out.println("Cannot return more copies than issued.");
void displayDetails() {
System.out.println("\nBook Details:"); getBookDetails(title,
author, totalCopies - issuedCopies);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Book Title: ");
String title = sc.nextLine();
System.out.print("Enter Book Author: ");
String author = sc.nextLine();
System.out.print("Enter Total Copies: "); int
totalCopies = sc.nextInt();
System.out.print("Enter Issued Copies: "); int
issuedCopies = sc.nextInt();
LibraryBook book = new LibraryBook(title, author, totalCopies, issuedCopies);
book.displayDetails();
System.out.print("\nEnter number of copies to issue: ");
int issueCopies = sc.nextInt(); book.issueBook(issueCopies);
System.out.print("\nEnter number of copies to return: ");
int returnCopies = sc.nextInt(); book.returnBook(returnCopies);
book.displayDetails();
sc.close();
}
}
4. Bank Management System – Handle Transactions
import
java.util.Scanner;
class BankAccount {
String accountHolder; int
accountNumber; double
balance;
String accountType;
BankAccount(String accountHolder, int accountNumber) {
this.accountHolder = accountHolder; this.accountNumber
= accountNumber;
this.balance = 0;
BankAccount(String accountHolder, int accountNumber, double balance)
{ this.accountHolder = accountHolder; this.accountNumber =
accountNumber; this.balance = balance;
BankAccount(String accountHolder, int accountNumber, double balance, String accountType)
{ this.accountHolder = accountHolder; this.accountNumber = accountNumber;
this.balance = balance; this.accountType = accountType;
void deposit(double amount) {
balance += amount;
System.out.println(amount + " deposited. New balance: " + balance);
void deposit(double amount, String currencyType) { double conversionRate
= (currencyType.equalsIgnoreCase("USD")) ? 1.2 : 1.0; balance += amount *
conversionRate;
System.out.println(amount + " " + currencyType + " deposited (converted). New balance: " + balance);
void withdraw(double amount) {
if (amount <= balance) { balance
-= amount;
System.out.println(amount + " withdrawn. New balance: " + balance);
} else {
System.out.println("Insufficient balance.");
void transferFunds(double amount, BankAccount recipient) {
if (amount <= balance) { balance -= amount;
recipient.balance += amount;
System.out.println(amount + " transferred to account " + recipient.accountNumber + ". New balance:
"
+ balance);
} else {
System.out.println("Insufficient balance for transfer.");
void displayAccountDetails() {
System.out.println("\nAccount Details:");
System.out.println("Account Holder: " + accountHolder);
System.out.println("Account Number: " + accountNumber);
System.out.println("Balance: " + balance); if (accountType
!= null) {
System.out.println("Account Type: " + accountType);
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Account Holder Name: ");
String accountHolder = sc.nextLine();
System.out.print("Enter Account Number: ");
int accountNumber = sc.nextInt();
System.out.print("Enter Initial Balance: "); double
balance = sc.nextDouble();
System.out.print("Enter Account Type (Savings/Current): "); sc.nextLine();
// Consume the newline character
String accountType = sc.nextLine();
BankAccount account1 = new BankAccount(accountHolder, accountNumber, balance, accountType);
account1.displayAccountDetails();
System.out.print("\nEnter amount to deposit: "); double
depositAmount = sc.nextDouble();
account1.deposit(depositAmount);
System.out.print("\nEnter amount to withdraw: ");
double withdrawAmount = sc.nextDouble();
account1.withdraw(withdrawAmount);
System.out.print("\nEnter amount to transfer: "); double
transferAmount = sc.nextDouble();
System.out.print("Enter recipient's account number: "); int
recipientAccountNumber = sc.nextInt();
// Create recipient account for the transfer
BankAccount recipientAccount = new BankAccount("Recipient", recipientAccountNumber, 1000,
"Savings"); account1.transferFunds(transferAmount,
recipientAccount);
recipientAccount.displayAccountDetails();
sc.close(); }
5. Medicine Inventory System – Manage Medicines and Expiry
import java.util.Scanner;
class Medicine {
String name; String
manufacturer; int
expiryYear; int
stockQuantity; double
price;
Medicine(String name, String manufacturer) {
this.name = name; this.manufacturer = manufacturer;
this.expiryYear = 0; this.stockQuantity = 0;
this.price = 0.0;
Medicine(String name, String manufacturer, int expiryYear, int stockQuantity) {
this.name = name; this.manufacturer = manufacturer; this.expiryYear = expiryYear;
this.stockQuantity = stockQuantity; this.price = 0.0;
Medicine(String name, String manufacturer, int expiryYear, int stockQuantity, double price) { this.name
= name; this.manufacturer = manufacturer; this.expiryYear = expiryYear; this.stockQuantity =
stockQuantity; this.price = price;
boolean isExpired(int expiryYear) { int
currentYear = 2025; return expiryYear <
currentYear;
boolean isExpired(int expiryYear, int manufactureYear) { int shelfLife
= expiryYear - manufactureYear; return shelfLife >
5; // Expired if shelf life is more than 5 years
boolean checkStock(int requiredQuantity) {
return stockQuantity >= requiredQuantity;
void updateStock(int quantityAdded, boolean isRestock) {
if (isRestock) { stockQuantity += quantityAdded;
System.out.println(quantityAdded + " units added to stock. New stock level: " + stockQuantity);
} else { if
(checkStock(quantityAdded)) { stockQuantity -=
quantityAdded;
System.out.println(quantityAdded + " units sold. New stock level: " + stockQuantity);
} else {
System.out.println("Insufficient stock.");
void displayDetails() {
System.out.println("\nMedicine Details:");
System.out.println("Name: " + name);
System.out.println("Manufacturer: " + manufacturer);
System.out.println("Expiry Year: " + expiryYear);
System.out.println("Stock Quantity: " + stockQuantity);
System.out.println("Price: " + price);
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Medicine Name: ");
String name = sc.nextLine();
System.out.print("Enter Manufacturer Name: ");
String manufacturer = sc.nextLine();
System.out.print("Enter Expiry Year: "); int
expiryYear = sc.nextInt();
System.out.print("Enter Stock Quantity: "); int
stockQuantity = sc.nextInt();
System.out.print("Enter Price: "); double
price = sc.nextDouble();
Medicine medicine = new Medicine(name, manufacturer, expiryYear, stockQuantity, price);
medicine.displayDetails();
System.out.print("\nEnter quantity to check stock: "); int
checkQuantity = sc.nextInt();
if (medicine.checkStock(checkQuantity)) {
System.out.println("Stock is available.");
} else {
System.out.println("Stock is not sufficient.");
System.out.print("\nEnter quantity to restock or sell: "); int
quantityChange = sc.nextInt();
System.out.print("Enter 1 to restock, 0 to sell: "); boolean
isRestock = sc.nextInt() == 1;
medicine.updateStock(quantityChange, isRestock);
System.out.print("\nCheck if the medicine is expired (Enter expiry year): "); int
expiryCheck = sc.nextInt(); if (medicine.isExpired(expiryCheck)) {
System.out.println("The medicine has expired.");
} else {
System.out.println("The medicine is not expired.");
System.out.print("\nEnter manufacture year to check shelf life: "); int
manufactureYear = sc.nextInt(); if
(medicine.isExpired(expiryYear, manufactureYear)) {
System.out.println("The medicine shelf life is too long and it has expired.");
} else {
System.out.println("The medicine is within shelf life.");
sc.close();