CLASS CHALLLENGE

 Create a new class for a bank account.
Create fields for the account number, balance, customer name,  email, and phone number.
Create getters and setters for each field.
Create two additional methods.
1. To allow the customer to deposit funds ( this should increment the balance field).
2. To allow the customer to withdraw funds ( this should decrement the balance field).
but not allow the withdraw to complete if there are insufficient funds.
You will want to create various code in the Main class ( the one created by IntelliJ) to confirm your code is working or not

package com.cnc;

public class BankAccount {
private long number;
private long balance;
private String customerName;
private String email;
private long phone;

public void deposit(double depositAmount){
this.balance += depositAmount;
System.out.println("Deposit of "+depositAmount+ " made. New balance is "+balance);
}
public void withdrawal(double withdrawalAmount){
if(balance - withdrawalAmount<0){
System.out.println("Only "+this.balance+" available.Withdrawal not processed");
}else {
this.balance -= withdrawalAmount;
System.out.println("Withdrawal of " + withdrawalAmount + "processed. Remaining balance ="+balance);
}
this.balance += withdrawalAmount;
}

public long getPhone() {
return phone;
}

public void setPhone(long phone) {
this.phone = phone;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getCustomerName() {
return customerName;
}

public void setCustomerName(String customerName) {
this.customerName = customerName;
}

public long getBalance() {
return balance;
}

public void setBalance(long balance) {
this.balance = balance;
}

public long getNumber() {
return number;
}

public void setNumber(long number) {
this.number = number;
}
}

Popular posts from this blog

NUMBER PALINDROME CHALLENGE

ENCAPSULATION CHALLENGE

LARGEST PRIME FACTOR OF A NUMBER