Java Lab - Exp - 3 - 21BCS8798 - Shivansh Kumar - CC-648
Java Lab - Exp - 3 - 21BCS8798 - Shivansh Kumar - CC-648
Java Lab - Exp - 3 - 21BCS8798 - Shivansh Kumar - CC-648
Experiment 1.3
Student Name: Shivansh Kumar UID: 21BCS8798
Branch: BE-CSE Section/Group: CC-648-B
th
Semester: 6 Date of Performance: 29-01-2024
Subject Name: Project Based Learning in Java with Lab
Subject Code: 21CSP-319
1. Aim:
Create an application to calculate interest for FDs, RDs based on certain
conditions using inheritance.
2. Objective:
Write a program to create an application to make an Account holders list and
calculate interest for FDs, RDs based on certain conditions using inheritance.
int noOfDays;
int ageOfACHolder;
double General, SCitizen;
Scanner FDScanner = new Scanner(System.in);
if (amount < 0) {
throw new InvalidAmountException();
}
if (noOfDays < 0) {
throw new InvalidDaysException();
}
if (ageOfACHolder < 0) {
throw new InvalidAgeException();
}
SCitizen = 0.0800;
} else if (noOfDays >= 185 && noOfDays <= 365) {
General = 0.0800;
SCitizen = 0.0850;
}
FDinterestRate = (ageOfACHolder < 50) ? General : SCitizen;
} else {
if (noOfDays >= 7 && noOfDays <= 14) {
interestRate = 0.065;
} else if (noOfDays >= 15 && noOfDays <= 29) {
interestRate = 0.0675;
} else if (noOfDays >= 30 && noOfDays <= 45) {
interestRate = 0.00675;
} else if (noOfDays >= 45 && noOfDays <= 60) {
interestRate = 0.080;
} else if (noOfDays >= 61 && noOfDays <= 184) {
interestRate = 0.0850;
} else if (noOfDays >= 185 && noOfDays <= 365) {
interestRate = 0.10;
}
}
return FDAmount * FDinterestRate;
}
}
if (RDamount < 0) {
throw new InvalidAmountException();
}
if (noOfMonths < 0) {
throw new InvalidMonthsException();
}
if (age < 0) {
throw new InvalidAgeException();
}
break;
default:
System.out.println("Wrong choice");
break;
}
}
sc.close();
}
}
Output: