Sumitra Sahoo ( 3 Assignment ) Answer
Sumitra Sahoo ( 3 Assignment ) Answer
Roll No – 82
import java.util.Scanner;
class StudentManagement {
studentRollNo; double[]
studentMarks; double
totalStudentMarks; double
studentPercentage;
= studentName;
this.studentRollNo = studentRollNo;
this.studentMarks = studentMarks;
double maxStudentMarks) {
this.studentName = studentName;
this.studentRollNo = studentRollNo;
this.totalStudentMarks = totalStudentMarks;
mark : marksArray) {
total += mark;
return total;
'A';
'B';
'C';
'F';
}
void displayDetails() {
System.out.println("\nStudent Details:");
if (studentMarks != null) {
mark : studentMarks) {
System.out.println();
of students
numSubjects = sc.nextInt();
sc.close();
import java.util.Scanner;
double basicSalary;
double taxRate; double
this.taxRate = taxRate;
Employee(String name, int empID, double basicSalary, double taxRate, double bonus) { this.name
= name;
this.bonus
= bonus;
}
double calculateAnnualSalary(double monthlySalary) {
void displayEmployeeDetails() {
System.out.println("\nEmployee Details:");
empID = sc.nextInt();
basicSalary = sc.nextDouble();
taxRate = sc.nextDouble();
System.out.print("Enter Bonus (0 if no bonus): "); double
bonus = sc.nextDouble();
Employee employee;
taxRate);
taxRate, bonus);
employee.displayEmployeeDetails();
sc.close();
class LibraryBook {
author; int
totalCopies; int
issuedCopies;
= author; this.totalCopies = 0;
this.issuedCopies = 0;
= author; this.totalCopies =
totalCopies; this.issuedCopies
= 0;
this.issuedCopies = issuedCopies;
(checkAvailability(requestedCopies)) {
issuedCopies += requestedCopies;
issued.");
} else {
issuedCopies -= returnedCopies;
} else {
void displayDetails() {
totalCopies = sc.nextInt();
issuedCopies = sc.nextInt();
book.displayDetails();
book.displayDetails();
sc.close();
}
}
class BankAccount {
accountNumber; double
balance;
String accountType;
= accountNumber;
this.balance = 0;
balance += amount;
System.out.println(amount + " deposited. New balance: " + balance);
conversionRate;
System.out.println(amount + " " + currencyType + " deposited (converted). New balance: " + balance);
-= amount;
} else {
System.out.println("Insufficient balance.");
recipient.balance += amount;
} else {
void displayAccountDetails() {
System.out.println("\nAccount Details:");
System.out.println("Account Holder: " + accountHolder);
!= null) {
balance = sc.nextDouble();
account1.displayAccountDetails();
depositAmount = sc.nextDouble();
account1.deposit(depositAmount);
System.out.print("\nEnter amount to withdraw: ");
account1.withdraw(withdrawAmount);
transferAmount = sc.nextDouble();
recipientAccountNumber = sc.nextInt();
recipientAccount);
recipientAccount.displayAccountDetails();
sc.close(); }
import java.util.Scanner;
class Medicine {
manufacturer; int
expiryYear; int
stockQuantity; double
price;
this.expiryYear = 0; this.stockQuantity = 0;
this.price = 0.0;
Medicine(String name, String manufacturer, int expiryYear, int stockQuantity, double price) { this.name
currentYear;
System.out.println(quantityAdded + " units added to stock. New stock level: " + stockQuantity);
} else { if
(checkStock(quantityAdded)) { stockQuantity -=
quantityAdded;
} else {
System.out.println("Insufficient stock.");
void displayDetails() {
System.out.println("\nMedicine Details:");
expiryYear = sc.nextInt();
stockQuantity = sc.nextInt();
price = sc.nextDouble();
medicine.displayDetails();
checkQuantity = sc.nextInt();
if (medicine.checkStock(checkQuantity)) {
System.out.println("Stock is available.");
} else {
quantityChange = sc.nextInt();
System.out.print("Enter 1 to restock, 0 to sell: "); boolean
isRestock = sc.nextInt() == 1;
medicine.updateStock(quantityChange, isRestock);
} else {
manufactureYear = sc.nextInt(); if
(medicine.isExpired(expiryYear, manufactureYear)) {
} else {
sc.close();