OneCompiler

Displaying required bank details

25

import java.util.*;
class account
{
String name;
int accountno;
String wallet;
int savings;
int current;
int num;
public account(String name,int accountno,String wallet,int savings,int current)
{
this.name=name;
this.accountno=accountno;
this.wallet=wallet;
this.savings=savings;
this.current=current;
}
public void display()
{
System.out.println("Name :\t" + name + "\nAccount no :\t" + accountno + "\nDigital wallet:\t" + wallet + "\nSavings account:\t" + savings + "\nCurrent account:\t"

  • current);
    }
    public static void getuser(account[] a,int num)
    {
    for(int i =0; i < a.length ; i++)
    {
    if(a[i].accountno == num)
    {
    a[i].display();
    }

    }
    System.out.println("Account not found");
    }
    }

public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter no of customers");
int n = sc.nextInt();
account a[] = new account[n];
for(int i = 0; i < n ; i++)
{
System.out.println("Enter name :");
String f = sc.next();
System.out.println("Enter Account no :");
int b = sc.nextInt();
System.out.println("Enter type of digital wallet:");
String c = sc.next();
System.out.println("Enter the amount in savings account:");
int d = sc.nextInt();
System.out.println("Enter the amount in current account:");
int e = sc.nextInt();
a[i] = new account(f,b,c,d,e);
}
System.out.println("Enter account no to display details");
int ac = sc.nextInt();
account.getuser(a,ac);
}
}