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

The question says: Create a subclass of the Account class called CheckingAccount

ID: 3536132 • Letter: T

Question

The question says: Create a subclass of the Account class called CheckingAccount. This class should have a constant called MAXCHECKS, an array of MAXCHECKS objects called checks, and an integer count of how many checks have been processed called numChecks. Each element of the checks array will contain an integer check number and a double amount for any check that is processed on the account. The CheckingAccount subclass should also have a processCheck(checkNumber: int, amount: double): String method that processes a check drawn on the account by withdrawing the amount from the balance if doing so does not cause an overdraft. The processCheck method should return "OK" if successful and the string "Processing check <checkNumber> would overdraft account" where <checkNumber is the relevant check number.

The part I am struggling with is creating the array that has both an int check number and double amount in each element of the array.

Here is the super class:

import java.util.Random;
public class Account {

//Instance Variables
private int accountNumber;
private double balance;

//Create a random 8 digit
private int get8DigitAccountNumber() {
Random random1 = new Random(8);
for (int i = 0; i < 8; i++) {
accountNumber = random1.nextInt(9);
}
return accountNumber;
}

//Default Constructor
public Account() {
accountNumber = get8DigitAccountNumber();
balance = 0;
}

//Overload Constructor
public Account(double beginningBalance) {
accountNumber = get8DigitAccountNumber();
balance = beginningBalance;
}

//Check Balance Method (Accessor)
public double checkBalance() {
return balance;
}

//Get Account Number Method (Accessor)
public int getAccountNumber() {
return accountNumber;
}

//Deposit Method
public void deposit(double amount) {
balance = balance + amount;
}

//Withdraw Method
public String withdraw(double amount) {
if(amount <= balance) {
balance = balance - amount;
return "OK";
}
else {
return "Withdrawl would overdraft account";
}
}
}

Thank you for your help!

Explanation / Answer

What you need to createa class called checks in Java, in your case it should be nX2 array. Where n is the no of records.

class Checks

{

int intcheck;

double doublecheck;

}

//then create an array


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