......................................................................................................................................................................
/* simple bank application program*/
public class InsufficientBalanceException extends Exception{
InsufficientBalanceException(){
super();
}
InsufficientBalanceException(String msg){
super(msg);
}
}
.....................................................................................................................................................................
public class FixedDepositeAccount extends Account {
public double callInterest(double amount){
System.out.println("....................................................................");
System.out.println("your Fixed deposite rate of interest is 9");
return amount+(amount*9)/100;
}
}
......................................................................................................................................................................
public class Customer {
String name;
String address;
double accountNO;
double currentBalance;
static Customer arr[]=new Customer[50];
}
.....................................................................................................................................................................
public class CurrAccount extends Account{
public double callInterest(double amount){
System.out.println("....................................................................");
System.out.println("your current account rate of interest is 8");
return amount+(amount*8)/100;
}
}
....................................................................................................................................................................
import java.util.Scanner;
public class Account extends BankApplication{
String accountType;
double accountNumber;
double minimumBalance;
double currentBalance;
static int k=0;
public static void main(String args[]) {
double q=5765647;
double balance;
int go=0,goba=0;
do{
Account Accountobj=new Account();
Scanner scan=new Scanner(System.in);
System.out.println(".............welcome to the Bank...................");
System.out.println("enter the account type\n"
+ "1- Fixed deposite\n"
+ "2- Current Account");
System.out.print("choice = ");
int accchoice=scan.nextInt();
if(accchoice==1){
Accountobj.setAccountType("Fixed deposite");
}
else{
Accountobj.setAccountType("Current Account");
}
System.out.println("account type is = "+Accountobj.getAccountType());
Accountobj.setAccountNumber(q++);
Accountobj.setMinimumBalance(100);
double accountNumber=Accountobj.getAccountNumber();
System.out.println();
System.out.println("enter the current balance of your account {minimum balance is 100}");
balance=scan.nextDouble();
Accountobj.setCurrentBalance(balance);
double currentBalance=Accountobj.getCurrentBalance();
try{
if(currentBalance<Accountobj.getMinimumBalance()){
throw new InsufficientBalanceException(" low balance ");
}
}
catch(Exception e){
System.out.println("hello... "+e);
}
System.out.println("do you go for bank applications press(1/0)");
System.out.print("choice = ");
System.out.println();
int ba=scan.nextInt();
if(ba==1){
do{
BankApplication BAobj=new Account();
BAobj.menuDisplay(accountNumber,currentBalance,k++);
System.out.println();
System.out.println("do you want to continue Bank Application press(1/0).. ");
System.out.print("choice = ");
goba=scan.nextInt();
}while(goba==1);
}
if(accchoice==1){
FixedDepositeAccount interestobj=new FixedDepositeAccount();
System.out.println("total amount is.."+interestobj.callInterest(currentBalance));
}
else{
CurrAccount interestobj=new CurrAccount();
System.out.println("total amount is.."+interestobj.callInterest(currentBalance));
}
System.out.println("are you a new customer press(1) ,press(0) for no customer..");
System.out.print("choice = ");
go=scan.nextInt();
}while(go==1);
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public double getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(double accountNumber) {
this.accountNumber = accountNumber;
}
public double getMinimumBalance() {
return minimumBalance;
}
public void setMinimumBalance(double minimumBalance) {
this.minimumBalance = minimumBalance;
}
public double getCurrentBalance() {
return currentBalance;
}
public void setCurrentBalance(double currentBalance) {
this.currentBalance = currentBalance;
}
}
--------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
public class BankApplication extends Customer{
String name;
String address;
double accountNO;
double currentBalance;
Scanner scan=new Scanner(System.in);
public void menuDisplay(double accNo,double currBal,int k){
System.out.println("select the choice\n"
+ "1- Add Customer\n"
+ "2- Delete Customer\n"
+ "3- update customer\n"
+ "4- coustmer information");
int choice=scan.nextInt();
BankApplication BAobj=new BankApplication();
switch(choice)
{
case 1:
BAobj.addCustomer(k,accNo,currBal);
break;
case 2:System.out.println("enter name of customer do you want to delete");
scan.nextLine();
String delName=scan.nextLine();
BAobj.deleteCustomer(delName,k);
break;
case 3:
BAobj.updateCustomer( k);
break;
case 4:
BAobj.getCustomerInfo(k);
break;
default:System.out.println("wrong choice..");
}
if(choice==2|choice==3){
k=k-1;
}
}
public void addCustomer(int k,double accNo,double currBal){
Customer obj1=new Customer();
System.out.println("....................................................................");
System.out.println();
System.out.println("enter the name of customer");
obj1.name=scan.nextLine();
System.out.println("enter the address");
obj1.address=scan.nextLine();
obj1.accountNO=accNo;
obj1.currentBalance=currBal;
arr[k]=obj1;
}
public void deleteCustomer(String delName,int k){
try{
System.out.println("....................................................................");
int q=-1;
for(int i=0;i<k;i++)
{
if(arr[i].name==delName){
q=i;
break;
}
}
if(q==-1){
System.out.println("this name customer is not found..");
}
else{
System.out.println("customer is deleted..");
for(int i=q;i<k-1;i++){
arr[i]=arr[i+1];
}
}
arr[k-1]=null;
}
catch(Exception e){
System.out.println("there is no customer..");
}
}
public void updateCustomer(int k){
Customer obj1=new Customer();
System.out.println("....................................................................");
int up=0;
//System.out.println("the total customer are "+(k));
System.out.println("select the customer number to which you want to update");
int cupdate=scan.nextInt();
do{
System.out.println();
System.out.println("which you want to update..\n"
+ "1- name\n"
+ "2- address\n"
+ "3- account number\n"
+ "4- current Balance");
System.out.print("choice = ");
int updatechoice=scan.nextInt();
switch(updatechoice)
{
case 1:System.out.println("enter the updated name of customer");
scan.nextLine();
String newname= scan.nextLine();
obj1.name=newname;
obj1.address=arr[cupdate].address;
obj1.accountNO=arr[cupdate].accountNO;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 2:System.out.println("enter the updated address");
scan.nextLine();
String newadd=scan.nextLine();
obj1.address=newadd;
obj1.name=arr[cupdate].name;
obj1.accountNO=arr[cupdate].accountNO;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 3: System.out.println("enter the updated account number");
double newno=scan.nextDouble();
obj1.accountNO=newno;
obj1.name=arr[cupdate].name;
obj1.address=arr[cupdate].address;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 4:System.out.println("enter the updated current Balance");
double currbal=scan.nextDouble();
obj1.currentBalance=currbal;
obj1.name=arr[cupdate].name;
obj1.address=arr[cupdate].address;
obj1.accountNO=arr[cupdate].accountNO;
arr[cupdate]=obj1;
}
System.out.println("do you want to update more info press(1/0)");
up=scan.nextInt();
}while(up==1);
}
public void getCustomerInfo(int k){
try{
System.out.println("....................................................................");
//System.out.println("the total customer are "+k);
System.out.println("select the customer number to which info you want to know..");
int cInfo=scan.nextInt();
System.out.println("the name is "+arr[cInfo].name);
System.out.println("the address is "+arr[cInfo].address);
System.out.println("the account number is "+arr[cInfo].accountNO);
System.out.println("the current balance is "+arr[cInfo].currentBalance);
}
catch(Exception e){
System.out.println("there is no customer..");
}
}
}
/* simple bank application program*/
public class InsufficientBalanceException extends Exception{
InsufficientBalanceException(){
super();
}
InsufficientBalanceException(String msg){
super(msg);
}
}
.....................................................................................................................................................................
public class FixedDepositeAccount extends Account {
public double callInterest(double amount){
System.out.println("....................................................................");
System.out.println("your Fixed deposite rate of interest is 9");
return amount+(amount*9)/100;
}
}
......................................................................................................................................................................
public class Customer {
String name;
String address;
double accountNO;
double currentBalance;
static Customer arr[]=new Customer[50];
}
.....................................................................................................................................................................
public class CurrAccount extends Account{
public double callInterest(double amount){
System.out.println("....................................................................");
System.out.println("your current account rate of interest is 8");
return amount+(amount*8)/100;
}
}
....................................................................................................................................................................
import java.util.Scanner;
public class Account extends BankApplication{
String accountType;
double accountNumber;
double minimumBalance;
double currentBalance;
static int k=0;
public static void main(String args[]) {
double q=5765647;
double balance;
int go=0,goba=0;
do{
Account Accountobj=new Account();
Scanner scan=new Scanner(System.in);
System.out.println(".............welcome to the Bank...................");
System.out.println("enter the account type\n"
+ "1- Fixed deposite\n"
+ "2- Current Account");
System.out.print("choice = ");
int accchoice=scan.nextInt();
if(accchoice==1){
Accountobj.setAccountType("Fixed deposite");
}
else{
Accountobj.setAccountType("Current Account");
}
System.out.println("account type is = "+Accountobj.getAccountType());
Accountobj.setAccountNumber(q++);
Accountobj.setMinimumBalance(100);
double accountNumber=Accountobj.getAccountNumber();
System.out.println();
System.out.println("enter the current balance of your account {minimum balance is 100}");
balance=scan.nextDouble();
Accountobj.setCurrentBalance(balance);
double currentBalance=Accountobj.getCurrentBalance();
try{
if(currentBalance<Accountobj.getMinimumBalance()){
throw new InsufficientBalanceException(" low balance ");
}
}
catch(Exception e){
System.out.println("hello... "+e);
}
System.out.println("do you go for bank applications press(1/0)");
System.out.print("choice = ");
System.out.println();
int ba=scan.nextInt();
if(ba==1){
do{
BankApplication BAobj=new Account();
BAobj.menuDisplay(accountNumber,currentBalance,k++);
System.out.println();
System.out.println("do you want to continue Bank Application press(1/0).. ");
System.out.print("choice = ");
goba=scan.nextInt();
}while(goba==1);
}
if(accchoice==1){
FixedDepositeAccount interestobj=new FixedDepositeAccount();
System.out.println("total amount is.."+interestobj.callInterest(currentBalance));
}
else{
CurrAccount interestobj=new CurrAccount();
System.out.println("total amount is.."+interestobj.callInterest(currentBalance));
}
System.out.println("are you a new customer press(1) ,press(0) for no customer..");
System.out.print("choice = ");
go=scan.nextInt();
}while(go==1);
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public double getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(double accountNumber) {
this.accountNumber = accountNumber;
}
public double getMinimumBalance() {
return minimumBalance;
}
public void setMinimumBalance(double minimumBalance) {
this.minimumBalance = minimumBalance;
}
public double getCurrentBalance() {
return currentBalance;
}
public void setCurrentBalance(double currentBalance) {
this.currentBalance = currentBalance;
}
}
--------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
public class BankApplication extends Customer{
String name;
String address;
double accountNO;
double currentBalance;
Scanner scan=new Scanner(System.in);
public void menuDisplay(double accNo,double currBal,int k){
System.out.println("select the choice\n"
+ "1- Add Customer\n"
+ "2- Delete Customer\n"
+ "3- update customer\n"
+ "4- coustmer information");
int choice=scan.nextInt();
BankApplication BAobj=new BankApplication();
switch(choice)
{
case 1:
BAobj.addCustomer(k,accNo,currBal);
break;
case 2:System.out.println("enter name of customer do you want to delete");
scan.nextLine();
String delName=scan.nextLine();
BAobj.deleteCustomer(delName,k);
break;
case 3:
BAobj.updateCustomer( k);
break;
case 4:
BAobj.getCustomerInfo(k);
break;
default:System.out.println("wrong choice..");
}
if(choice==2|choice==3){
k=k-1;
}
}
public void addCustomer(int k,double accNo,double currBal){
Customer obj1=new Customer();
System.out.println("....................................................................");
System.out.println();
System.out.println("enter the name of customer");
obj1.name=scan.nextLine();
System.out.println("enter the address");
obj1.address=scan.nextLine();
obj1.accountNO=accNo;
obj1.currentBalance=currBal;
arr[k]=obj1;
}
public void deleteCustomer(String delName,int k){
try{
System.out.println("....................................................................");
int q=-1;
for(int i=0;i<k;i++)
{
if(arr[i].name==delName){
q=i;
break;
}
}
if(q==-1){
System.out.println("this name customer is not found..");
}
else{
System.out.println("customer is deleted..");
for(int i=q;i<k-1;i++){
arr[i]=arr[i+1];
}
}
arr[k-1]=null;
}
catch(Exception e){
System.out.println("there is no customer..");
}
}
public void updateCustomer(int k){
Customer obj1=new Customer();
System.out.println("....................................................................");
int up=0;
//System.out.println("the total customer are "+(k));
System.out.println("select the customer number to which you want to update");
int cupdate=scan.nextInt();
do{
System.out.println();
System.out.println("which you want to update..\n"
+ "1- name\n"
+ "2- address\n"
+ "3- account number\n"
+ "4- current Balance");
System.out.print("choice = ");
int updatechoice=scan.nextInt();
switch(updatechoice)
{
case 1:System.out.println("enter the updated name of customer");
scan.nextLine();
String newname= scan.nextLine();
obj1.name=newname;
obj1.address=arr[cupdate].address;
obj1.accountNO=arr[cupdate].accountNO;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 2:System.out.println("enter the updated address");
scan.nextLine();
String newadd=scan.nextLine();
obj1.address=newadd;
obj1.name=arr[cupdate].name;
obj1.accountNO=arr[cupdate].accountNO;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 3: System.out.println("enter the updated account number");
double newno=scan.nextDouble();
obj1.accountNO=newno;
obj1.name=arr[cupdate].name;
obj1.address=arr[cupdate].address;
obj1.currentBalance=arr[cupdate].currentBalance;
arr[cupdate]=obj1;
break;
case 4:System.out.println("enter the updated current Balance");
double currbal=scan.nextDouble();
obj1.currentBalance=currbal;
obj1.name=arr[cupdate].name;
obj1.address=arr[cupdate].address;
obj1.accountNO=arr[cupdate].accountNO;
arr[cupdate]=obj1;
}
System.out.println("do you want to update more info press(1/0)");
up=scan.nextInt();
}while(up==1);
}
public void getCustomerInfo(int k){
try{
System.out.println("....................................................................");
//System.out.println("the total customer are "+k);
System.out.println("select the customer number to which info you want to know..");
int cInfo=scan.nextInt();
System.out.println("the name is "+arr[cInfo].name);
System.out.println("the address is "+arr[cInfo].address);
System.out.println("the account number is "+arr[cInfo].accountNO);
System.out.println("the current balance is "+arr[cInfo].currentBalance);
}
catch(Exception e){
System.out.println("there is no customer..");
}
}
}
No comments:
Post a Comment