Exp 3
Exp 3
Experiment 3
Student Name: Aakanksha Sharma UID:22BCS16783
Branch: BE-CSE Section/Group: IOT-632/A
Semester:6th Date of Performance:27-01-25
Subject Name: Project Based Learning Subject Code: 22CSH-359
in Java with Lab
1. Aim: Calculate interest based on the type of the account and the status of the account
holder. The rates of interest changes according to the amount (greater than or less than
1 crore), age of account holder (General or Senior citizen) and number of days if the
type of account is FD or RD
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
2. Objective: Separate classes should be created for the different types of accounts. All
classes should be derives from an abstract class named ‘Account’ which contains a
method called ‘calculateInterest’. Implement the calculateInterest method according to the
type of the account, interest rates, amount and age of the account holder. 4If the user is
entering any invalid value (For eg. Negative value) in any fields, raise a user defined
exception.
3. Implementation/Code:
import java.util.Scanner;
class SBAccount {
private double balance;
class FDAccount {
private double principal; private
int tenure;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
class RDAccount {
private double monthlyDeposit; private
int tenure;
int option;
do {
System.out.println("\nSelect the option:");
System.out.println("1. Interest Calculator – SB");
System.out.println("2. Interest Calculator – FD");
System.out.println("3. Interest Calculator – RD");
System.out.println("4. Exit"); System.out.print("Enter
your choice: ");
option = scanner.nextInt();
switch (option) {
case 1: // SB Account
System.out.print("Enter balance in your SB Account: ");
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
double sbBalance = scanner.nextDouble(); SBAccount
sbAccount = new SBAccount(sbBalance);
System.out.printf("\n*********************\n");
System.out.printf(" Hello, %s! \n", name);
System.out.printf(" Interest Gained (SB): ₹ %.2f \n",
sbAccount.calculateInterest());
System.out.printf("*********************\n");
break;
case 2 : // FD Account
System.out.print("Enter principal amount for FD: "); double
principal = scanner.nextDouble(); System.out.print("Enter
tenure (in years): ");
int fdTenure = scanner.nextInt();
FDAccount fdAccount = new FDAccount(principal, fdTenure);
System.out.printf("\n*********************\n");
System.out.printf(" Hello, %s! \n", name); System.out.printf("
Interest Gained (FD): ₹ %.2f \n",
fdAccount.calculateInterest());
System.out.printf("*********************\n");
break;
case 3: // RD Account
System.out.print("Enter monthly deposit for RD: "); double
monthlyDeposit = scanner.nextDouble();
System.out.print("Enter tenure (in months): ");
int rdTenure = scanner.nextInt();
RDAccount rdAccount = new RDAccount(monthlyDeposit, rdTenure);
System.out.printf("\n*********************\n"); System.out.printf("
Hello, %s! \n", name);
System.out.printf(" Interest Gained (RD): ₹ %.2f \n",
rdAccount.calculateInterest());
System.out.printf("*********************\n");
break;
case 4: // Exit
System.out.println("\nThank you for using the Interest Calculator. Goodbye!");
break;
default:
System.out.println("\nInvalid choice. Please try again.");
}
} while (option != 4);
scanner.close();
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
4.Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Learning Outcomes:
• Designed a functional system to manage video rentals, demonstrating the use of
classes and objects in Java.
• Implemented methods for operations like adding videos, renting out, returning, and
recording user ratings.
• Applied arrays to store and efficiently manage the video inventory within the store.
• Learnt to integrate multiple classes and enable seamless interaction among them in
a structured program.