Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package package1;
- import java.util.*;
- public class Account {
- ArrayList<Transactions> List2= new ArrayList<Transactions>();
- //Variables
- protected String date;
- protected String name;
- protected int Account_num;
- protected double AnuualInterestRate;
- protected double Balance;
- // constructors
- public Account () {}
- public Account (int Date, String name, int Account_num, int Balance ,Double AnuualInterestRate) {
- this.name=name;
- this.AnuualInterestRate=AnuualInterestRate;
- this.Balance=Balance;
- this.Account_num=Account_num;
- }
- // getters and setters
- public String getDate() {
- return date;
- }
- public void setDate(String date) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the Date ");
- date = in.nextLine();
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the Name ");
- name = in.nextLine();
- }
- public int getAccount_num() {
- return Account_num;
- }
- public void setAccount_num(int account_num) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the ID ");
- account_num = in.nextInt();
- }
- public double getAnuualInterestRate() {
- return AnuualInterestRate;
- }
- public void setAnuualInterestRate(double anuualInterestRate) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the AnuualInterestRate ");
- anuualInterestRate = in.nextDouble();
- }
- public double getBalance() {
- return Balance;
- }
- public void setBalance(double balance) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the AnuualInterestRate ");
- balance = in.nextDouble();
- }
- //Transactions Methods
- //1)withdraw
- public double Withdrawal(double amount) {
- if(Balance< amount) {
- System.out.println("Invalid Amount");
- }
- else if (amount > 8000) {
- System.out.println("Invalid");
- }
- else {
- Transactions t = new Transactions(new Date (), amount,'W');
- List2.add(t);
- Balance -=amount;
- }
- return Balance;
- }
- //2)deposit
- public double Deposit(double amount) {
- Transactions t = new Transactions(new Date (), amount,'D');
- List2.add(t);
- Balance += amount;
- return Balance;
- }
- //3)AnnualInterestRate
- public double AnuualInterestRate() {
- Transactions t = new Transactions(new Date (),'R');
- List2.add(t);
- Balance +=(Balance *0.015);
- return Balance ;
- }
- //Display Methods
- //1) Transactions
- void DisplayTransactions() {
- for(int i=0 ; i<List2.size() ; i++) {
- System.out.println(List2.get(i).date +" "+List2.get(i).transaction +" " + List2.get(i).amount);
- }
- }
- //2)Account
- void DisplayAccountInformation() {
- System.out.println("Customer Name : "+name );
- System.out.println("ID : "+Account_num );
- System.out.println("Date : "+date );
- System.out.println("Current Balance : "+Balance );
- System.out.println("\n");
- System.out.println("------------------After Transaction------------------");
- DisplayTransactions();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement