Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using eclipse 4 classes must be defined Paragraph Styles Problem (25 points) Fir

ID: 3920454 • Letter: U

Question

Using eclipse 4 classes must be defined Paragraph Styles Problem (25 points) First American Bank provides both normal bank services like checking accounts and mortgages to its customers. Each customer who uses checking services has a checking account. Each customer who gets a mortgage loan from the bank has a mortgage account The bank executives ask a team of software analysts to develop a system to manage its customers' bank accounts Section A: Define an abstract Java class named "BankAccount" in a package named BANKACCOUNTS, This class has three attributes: (1) Acount number: an integer of 10 digits, defined as protected (2) Account type: String (e.g.: "CHECKING versus "MORTGAGE"), defined as . protected (3) Customers full name: String, defined as protected Class BankAccount definition provides . a default constructor . get-methods and set-methods for the variable attributes, . a public method, named "displayAccountData0", that prints out the following pieces of data: account number, account type, and customer's full name in only one line. Section B: Define a Java class named CheckingAccount in the same package, BANKACCOUNTS that extends the class BankAccount. Class CheckingAccount has only one attribute: checking balance, that is defined as private. . Class CheckingAccount definition provides: 19 f10 112 break

Explanation / Answer

abstract class BankAccount{
protected long accountNumber;
protected String type;
protected String customerName;

public BankAccount(){

}

public void setAccountNumber(long ac){
accountNumber = ac;
}

public void setAccountType(String t){
if(t.equals("CHECKING") || t.equals("MORTGAGE")){
   type = t;
}
}

public void setCustomerName(String name){
customerName = name;
}

public String getAccountType(){
return type;
}

public String getCustomerName(){
return customerName;
}

public long getAccountNumber(){
return accountNumber;
}

abstract public void displayAccountData();
}

---------------------------------------------------------
class CheckingAccount extends BankAccount{
private double balance;

public CheckingAccount(){

}

public void setBalance(double b){
balance = b;
}

public double getBalance(){
return balance;
}

public void displayAccountData(){
System.out.println("Account Number : "+accountNumber);
System.out.println("Account Type : "+type);
System.out.println("Customer Name : "+customerName);
System.out.println("Checking Balance : "+balance);
}
}

--------------------------------------------------------------------------------------------------------------
class MortgageAccount extends BankAccount{
private double balance;
private int rate;

public MortgageAccount(){

}

public void setPrincipalBalance(double p){
balance = p;
}

public void setInterestRate(int r){
rate = r;
}

public int getInterestRate(){
return rate;
}

public double getPrincipalBalance(){
return balance;
}

public void displayAccountData(){
System.out.println("Account Number : "+accountNumber);
System.out.println("Account Type : "+type);
System.out.println("Customer Name : "+customerName);
System.out.println("Principal Balance : "+balance);
System.out.println("Interest Rate : "+rate+"%");
}
}

--------------------------------------------------------------------------------------------------------
import java.util.Scanner;

class AccountDisplayer{
public static void main(String[] args) {
int type;

Scanner sc = new Scanner(System.in);

while(true){
   System.out.println("Enter the account code : ");
   type = sc.nextInt();
   if(type == 1 || type == 2){
    break;
   }else{
    System.out.println("Enter code 1 for checking or 2 for mortgage ");
   }
}

if(type == 1){
   CheckingAccount b = new CheckingAccount();
   System.out.println("Enter Customer First Name : ");
   String n1 = sc.next();
   System.out.println("Enter Customer Last Name : ");
   String n2 = sc.next();
   b.setCustomerName(n1+" "+n2);
   System.out.println("Enter Account Number ");
   b.setAccountNumber(sc.nextLong());
   while(true){
    System.out.println("Enter The Checking Balance : ");
    double bal = sc.nextDouble();
    if(bal >= 0){
     b.setBalance(bal);
     break;
    }
   }
   b.setAccountType("CHECKING");

   b.displayAccountData();
}
else{
   MortgageAccount b = new MortgageAccount();
   System.out.println("Enter Customer First Name : ");
   String n1 = sc.next();
   System.out.println("Enter Customer Last Name : ");
   String n2 = sc.next();
   b.setCustomerName(n1+" "+n2);
   System.out.println("Enter Account Number ");
   b.setAccountNumber(sc.nextLong());
   while(true){
    System.out.println("Enter The Principal Balance : ");
    double bal = sc.nextDouble();
    if(bal >= 0){
     b.setPrincipalBalance(bal);
     break;
    }
   }
   while(true){
    System.out.println("Enter The Interest Rate : ");
    int rate = sc.nextInt();
    if(rate >= 0){
     b.setInterestRate(rate);
     break;
    }
   }
   b.setAccountType("MORTGAGE");

   b.displayAccountData();
}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote