0% found this document useful (0 votes)
21 views6 pages

Java 4

Uploaded by

harsha14203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

Java 4

Uploaded by

harsha14203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import java.io.

BufferedReader;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.Scanner;

class Account

protected int accnumber;

double balance;

Account()

accnumber=0;

balance=0;

Account(int accountnumber,double init_balance)

accnumber=accountnumber;

balance=init_balance;

class SBAccount extends Account

SBAccount(int accountnumber,double init_balance)

super(accountnumber,init_balance);

void deposit(double amount)

if(amount>0)

balance+=amount;

}
System.out.println("After deposition of "+amount+"Rs then the balance is : "+balance);

void withdraw(double amount)

if((balance-amount)>1000)

balance-=amount;

System.out.println("After withdrawal of "+amount+"Rs then the balance is : "+balance);

else

System.out.println("\nSorry!!!You cannot withdraw the amount\nBalance is : "+balance);

void calc_interest()

balance=balance+((balance*4*1)/100);

System.out.println("After calculating interest for 5 year of interest 2.5% the balance is : "+balance);

class Customer extends SBAccount

int cust_id;

String name,address;

Customer(int accountnumber,double initialbalance,int cust_id,String name,String address)

super(accountnumber,initialbalance);

this.cust_id=cust_id;

this.name=name;

this.address=address;

}
void transaction()

System.out.print("\n\tMENU\n1 Withdraw\n2 Deposit\n3 Calculate Interest\nEnter your choice


(1to3) : ");

Scanner inp=new Scanner(System.in);

int n=inp.nextInt();

double amount;

switch(n)

case 1:

System.out.print("\n\tWithDraw\nEnter the amount to be withdraw : ");

amount=inp.nextDouble();

withdraw(amount);

break;

case 2:

System.out.print("\n\tDeposit\nEnter the amount to be deposited : ");

amount=inp.nextDouble();

deposit(amount);

break;

case 3:

System.out.print("\n\tCalculating Interest\n");

calc_interest();

break;

case 4:

System.out.print("\n\tFinal Detail\n");

result();

break;

default:

System.out.println("\nYou entered wrong choice");

break;

}
}

void result()

System.out.println("\n\tCustomer Final Detail\nCustomer ID : "+cust_id+"\nName :


"+name+"\nAccount Number : "+accnumber+"\nAdderss : "+address+"\nFinal Balance :
"+balance+"\n\n");

class Ban

public static void main(String s[])throws IOException

Customer c[]=new Customer[5];

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.println("\n\tGetting input from user");

for(int i=0;i<5;i++)

System.out.print("\n\n\tCustomer "+(i+1)+"\nEnter name : ");

String name=b.readLine();

System.out.print("Enter address : ");

String address=b.readLine();

System.out.print("Enter customer id : ");

int id=Integer.parseInt(b.readLine());

System.out.print("Enter account number : ");

int accno=Integer.parseInt(b.readLine());

System.out.print("Enter initial balance : ");

double balance=Double.parseDouble(b.readLine());

c[i]=new Customer(accno,balance,id,name,address);

for(int i=0;i<5;i++)

System.out.println("\n\n\tCustomer "+(i+1));
c[i].transaction();

c[i].result();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy