package
College;
import
java.util.Scanner;
public
class
InterestCalculator {
public
static
void
main(String[] args)
{
Scanner sc =
new
Scanner(System.in);
System.out.println(
"SELECT THE OPTIONS "
+
"\n1."
+ " Interest Calculator-Saving
Account
" + "
\n2.
" + "
Interest Calculator
- Fixed Deposit "
+
"\n3."
+
" InterestCalculator-Recurring Deposits"
+
"\n4 "
+
" Exit"
);
int
choice = sc.nextInt();
switch
(choice) {
case
1
:
SBaccount sb =
new
SBaccount();
try
{
System.out.println(
"Enter the Average SB amount "
);
double
amount = sc.nextDouble();
System.out.println(
"Interest gained is : $ "
+ sb.calculateInterest(amount));
}
catch
(InvalidAmountException e) {
System.out.println(
"Exception : Invalid amount"
);
}
break
;
case
2
:
try
{
FDaccount fd =
new
FDaccount();
System.out.println(
"Enter the FD Amount"
);
double
fAmount = sc.nextDouble();
System.out.println(
"Interest gained is: $ "
+ fd.calculateInterest(fAmount));
}
catch
(InvalidAgeException e) {
System.out.println(
"Invalid Age Entered"
);
}
catch
(InvalidAmountException e) {
System.out.println(
"Invalid Amount Entered"
);
}
catch
(InvalidDaysException e) {
System.out.println(
"Invalid Days Entered"
);
}
break
;
case
3
:
try
{
RDaccount rd =
new
RDaccount();
System.out.println(
"Enter the RD amount"
);
double
Ramount = sc.nextDouble();
System.out.println(
"Interest gained is: $ "
+ rd.calculateInterest(Ramount));
}
catch
(InvalidAgeException e) {
System.out.println(
"Invalid Age Entered"
);
}
catch
(InvalidAmountException e) {
System.out.println(
"Invalid Amount Entered"
);
}
catch
(InvalidMonthsException e) {
System.out.println(
"Invalid Days Entered"
);
}
break
;
case
4
:
System.out.println(
"DO YOU WANT TO CALCULATE AGAIN ????"
+
" "
+
"RUN AGAIN THE PROGRAM"
);
default
:
System.out.println(
"Wrong choice"
);
}
}
}