Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Application {
- public static void main(String[] args) {
- Scanner userInput = new Scanner(System.in);
- //Account[] A=new Account[50];
- Savings [] SA = new Savings[50];
- Current [] CA = new Current[50];
- Student [] sa = new Student[50];
- int a=0,i=-1,j=-2,x;
- do{
- System.out.println(".....Welcome To My Banking System.....");
- System.out.println("Want to open a new accout? Press 1:");
- System.out.println("Want to work with your account? Press 2:");
- System.out.println("Want to Exit:Press 3:");
- System.out.println("Enter Your Choice:");
- x=userInput.nextInt();
- if(x==1){
- System.out.println("...Account Type...");
- System.out.println("1.For Savings Account Write:'Savings'");
- System.out.println("2.For Current Account Write:'Current'");
- System.out.println("3.For Student Account Write:'Student'");
- System.out.println("What Type Of Account Want To Make? Enter Your choice:");
- String c1=userInput.next();
- i++;
- if(c1.equals("Savings")){
- System.out.println("Enter your Name:");
- String name=userInput.next();
- System.out.println("Enter your Balance:");
- double balance=userInput.nextDouble();
- SA[i]=new Savings(name,balance);
- System.out.println("Account Holder Name:"+SA[i].getMemberName() + "Account Holder Id:"+SA[i].getAccountNumber());
- }
- else if(c1.equals("Current")){
- System.out.println("Enter your Name:");
- String name=userInput.next();
- System.out.println("Enter your Balance:");
- double balance=userInput.nextDouble();
- System.out.println("Enter your TreadLisence:");
- int trdLisence=userInput.nextInt();
- CA[i]=new Current(name, balance,trdLisence);
- System.out.println("Account Holder Name:"+CA[i].getMemberName() + "Account Holder Id:"+CA[i].getAccountNumber());
- }
- else if(c1.equals("Student")){
- System.out.println("Enter your Name:");
- String name=userInput.next();
- System.out.println("Enter your Balance:");
- double balance=userInput.nextDouble();
- System.out.println("Enter your Institute:");
- String inst=userInput.next();
- sa[i]=new Student(name,balance,inst);
- System.out.println("Account Holder Name:"+sa[i].getMemberName() + "Account Holder Id:"+sa[i].getAccountNumber());
- }
- }
- else if(x==2) {
- System.out.println("Input Your Id:");
- String y = userInput.next();
- for (j = 0; j <= i; j++) {
- if (y.equals(SA[j].getAccountNumber())) {
- break;
- }
- }
- }
- if(j>=0){
- do{
- System.out.println("Want to Deposite Money Press 1:");
- System.out.println("Want to Withdrawl Money Press 2:");
- System.out.println("Want Display Account Details Press 3:");
- System.out.println("Return to Banking System Press 0:");
- a= userInput.nextInt();
- if (a == 1) {
- System.out.println("Enter How Much Money You Want TO Deposite:");
- double ammount= userInput.nextDouble();
- SA[j].deposite(ammount);
- }
- else if (a== 2) {
- System.out.println("Enter How Much Money You Want TO Withdrawl:");
- double ammount= userInput.nextDouble();
- SA[j].withdrawl(ammount);
- }
- else if (a == 3) {
- SA[j].display();
- }
- else{
- System.out.println("Exit from account");
- break;
- }
- }while(a!=0);
- }
- }while(x!=0);
- }
- }
- import java.util.Random;
- public class BankAccount {
- String memberName;
- String accountNumber;
- double accountBalance;
- double minimumBalance;
- public String getMemberName(){
- return memberName;
- }
- public void setMemberName(String memberName) {
- this.memberName = memberName;
- }
- public String getAccountNumber() {
- return accountNumber;
- }
- public void setAccountNumber(String accountNumber){
- this.accountNumber = accountNumber;
- }
- public double getAccountBalance(){
- return accountBalance;
- }
- public void setAccountBalance(double accountBalance) {
- this.accountBalance = accountBalance;
- }
- public BankAccount(String memberName,double accountBalance,double minimumBalance){
- this.memberName =memberName;
- this.accountBalance =accountBalance;
- this.minimumBalance=minimumBalance;
- Random rand=new Random();
- this.accountNumber =10000+rand.nextInt(89999)+"";
- }
- public void deposite(double ammount)
- {
- setAccountBalance(getAccountBalance()+ammount);
- }
- void withdrawl(double ammount)
- {
- double withdraw;
- withdraw = accountBalance -ammount;
- if(withdraw >= minimumBalance){
- accountBalance = withdraw;
- }
- }
- public double getBalance() {
- return accountBalance;
- }
- void display(){
- System.out.println("Name:"+ getMemberName()+" "+"Id:"+ getAccountNumber()+" "+"Balance:"+ getAccountBalance());
- }
- }
- public class Current extends BankAccount{
- public int tradeLicense;
- public Current(String name,double balance,int trdLicense) {
- super(name, balance,5000);
- this.tradeLicense=trdLicense;
- }
- }
- public class Savings extends BankAccount {
- double interest=0.05;
- double MaxWithdrawLimit;
- public Savings(String name, double balance) {
- super(name, balance, 2000);
- MaxWithdrawLimit =50000 ;
- }
- public double getBalance(int year){
- return getAccountBalance()+(getAccountBalance()*interest)*year;
- }
- public double getOriginalBalance(){
- return accountBalance;
- }
- }
- public class Student extends Savings {
- String institute;
- public Student(String name,double balance,String inst){
- super(name,balance);
- this.institute = inst;
- MaxWithdrawLimit =20000;
- minimumBalance=100;
- }
- }
Add Comment
Please, Sign In to add comment