Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
- */
- package customer;
- /**
- *
- * @author urvil
- */
- import java.util.*;
- import java.util.Scanner;
- public class Customer extends bank {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int choice;
- ArrayList<bank> a1 = new ArrayList<bank>();
- String s;
- double a;
- int i;
- Scanner sc=new Scanner(System.in);
- do
- {
- System.out.println("1. Register");
- System.out.println("2. Display");
- System.out.println("3. Withdraw");
- System.out.println("4. Deposit");
- System.out.println("5. Search");
- System.out.println("6.Exit");
- choice=sc.nextInt();
- sc.nextLine();
- switch(choice)
- {
- case 1:
- bank b = new bank();
- a1.add(b);
- break;
- case 2:
- System.out.println("id\tname\ttype\tbalance");
- for(bank elements:a1)
- elements.display();
- break;
- case 3:
- System.out.println("Enter account name");
- s=sc.nextLine();
- System.out.println("Enter amount");
- a=sc.nextDouble();
- for(bank m1:a1)
- if(s.equals(m1.name))
- m1.withdraw(a);
- break;
- case 4:
- System.out.println("Enter the you want search movie");
- s=sc.nextLine();
- System.out.println("enter amount");
- a=sc.nextInt();
- for(bank m1:a1)
- if(s.equals(m1.name))
- m1.deposit(a);
- break;
- case 5:
- System.out.println("Enter Id");
- i=sc.nextInt();
- for(bank m1:a1)
- if(i == m1.id)
- m1.display();
- break;
- }
- }while(choice!=6);
- }
- }
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
- */
- package customer;
- /**
- *
- * @author urvil
- */
- import java.util.*;
- import java.util.Scanner;
- interface functions{
- public void display();
- public String getType();
- public String getName();
- public double withdraw(double amt);
- public void draft(double amt);
- public double deposit(double amt);
- }
- public class bank implements functions {
- protected String type,name;
- protected int id;
- protected double balance,amount;
- Scanner sc = new Scanner(System.in);
- public bank()
- {
- System.out.println("Enter id");
- id = sc.nextInt();
- sc.nextLine();
- System.out.println("Enter name");
- name = sc.nextLine();
- System.out.println("Enter account type(s or c)");
- type = sc.nextLine();
- System.out.println("Enter balance");
- if(type.equals("s"))
- {
- balance = sc.nextDouble();
- balance+=balance*3/100;
- }
- else
- balance = sc.nextDouble();
- }
- @Override
- public String getType()
- {
- return type;
- }
- @Override
- public String getName(){
- return name;
- }
- @Override
- public void display() {
- System.out.println(id+"\t"+name+"\t"+type+"\t"+balance);
- }
- @Override
- public double withdraw(double amt){
- return balance-=amt;
- }
- @Override
- public double deposit(double amt){
- return balance+=amt;
- }
- @Override
- public void draft(double amt) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement