Java Assignment-3
Java Assignment-3
ROLL NO – 37
REG.NO – 2405432040
1.
class Student {
this.name = name;
this.rollNo = rollNo;
this.name = name;
this.rollNo = rollNo;
this.totalMarks = calculateTotal(marks);
this.grade = getGrade(this.percentage);
this.name = name;
this.rollNo = rollNo;
this.totalMarks = totalMarks;
this.maxMarks = maxMarks;
this.percentage = calculatePercentage(totalMarks, maxMarks);
this.grade = getGrade(this.percentage);
double total = 0;
total += mark;
return total;
student1.displayDetails();
student2.displayDetails();
2.
class Employee {
this.name = name;
this.empID = empID;
this.name = name;
this.empID = empID;
this.basicSalary = basicSalary;
this.taxRate = taxRate;
public 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;
emp1.displayDetails();
emp2.displayDetails();
3.
class LibraryBook {
this.author = author;
this.totalCopies = 1;
this.issuedCopies = 0;
this.author = author;
this.totalCopies = totalCopies;
this.issuedCopies = 0;
this.author = author;
this.totalCopies = totalCopies;
this.issuedCopies = issuedCopies;
System.out.println("Title: " + tle + ", Author: " + author + ", Copies Available: " + copiesAvailable);
if (checkAvailability(copies)) {
issuedCopies += copies;
} else {
issuedCopies -= copies;
} else {
book1.getBookDetails("Java Programming");
book1.issueBook(2);
book1.displayBookStatus();
book1.returnBook(1);
book1.displayBookStatus();
4.
class BankAccount {
this.accountHolder = accountHolder;
this.accountNumber = accountNumber;
this.balance = 0.0;
this.accountHolder = accountHolder;
this.accountNumber = accountNumber;
this.balance = balance;
this.accountHolder = accountHolder;
this.accountNumber = accountNumber;
this.balance = balance;
this.accountType = accountType;
if (amount > 0) {
balance += amount;
} else {
deposit(convertedAmount);
System.out.println("Deposited: " + amount + " " + currencyType + " (Converted to " + convertedAmount + "
USD)");
balance -= amount;
return true;
} else {
return false;
if (withdraw(amount)) {
recipient.deposit(amount);
return true;
} else {
System.out.println("Transfer failed.");
return false;
switch (currencyType.toUpperCase()) {
if (accountType != null) {
acc1.deposit(1000);
acc1.deposit(500, "EUR");
acc1.withdraw(2000);
acc1.transferFunds(1500, acc2);
acc1.displayAccountDetails();
acc2.displayAccountDetails();
5.
import java. me.Year;
class Medicine {
this.name = name;
this.manufacturer = manufacturer;
public Medicine(String name, String manufacturer, int expiryYear, int stockQuan ty) {
this.name = name;
this.manufacturer = manufacturer;
this.expiryYear = expiryYear;
public Medicine(String name, String manufacturer, int expiryYear, int stockQuan ty, double price) {
this.name = name;
this.manufacturer = manufacturer;
this.expiryYear = expiryYear;
this.price = price;
if (isRestock) {
} else {
med1.displayMedicineDetails();
med1.updateStock(20, true);
med1.updateStock(30, false);