Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me figure out what I am doing wrong. And please DO NOT use the same WRONG credit card answer I have seen on

Please help me figure out what I am doing wrong. And please DO NOT use the same WRONG credit card answer I have seen on the previous answers. Please tweak my work and help me know where it is messing up.

image text in transcribed

image text in transcribed

image text in transcribed

public abstract class BankAccount { protected String accountID = "0000-0000-0000-0000"; protected double interestRate = 0.0; protected int balance = 0; public boolean credit(int pennies) { this.balance += pennies; return true; } public abstract boolean debit(int pennies); public int getBalance() { return balance; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } public double getInterestRate() { return interestRate; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public abstract void applyInterest(); public abstract String accountInfo(); }

public class Main { public static void main(String[] args) { } }

public class CheckingAccount extends BankAccount { private int overdraftFee = 0; @Override public boolean debit(int pennies) { if((this.balance - pennies) 0) { balance += (balance * interestRate); }

} @Override public String accountInfo() { return String.format( "Type of Account : Checking " + "Account ID : %s " + "Current Balance : $%.2f " + "Interest rate : %2.2f%% " + "Overdraft Fee : $%2.2f ", this.getAccountID(), this.getBalance(), (interestRate * 100), this.overdraftFee); } }

Below is how the program is graded and where my code is messing up

image text in transcribedimage text in transcribed

thank you!! if it works I will definitely upvote!!

Problem Description and Given Info You must write a public class named CheckingAccount with fields and methods as defined below, and that inherits from (extends) the BankAccount class. \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Inherits/Extends } \\ \hline CheckingAccount \\ \hline - overdraftFee : int \\ \hline + debit(pennies : int) : boolean + getFee() : int + setFee(overdraftFee : int) + applyInterest() + accountInfo() : String \\ \hline \end{tabular} UML CLass Diagram: CheckingAccount Inherits BankAccount Structure of the Fields As described by the UML Class Diagram above, your CheckingAccount class must have the following fields: - a private field named overdraftFee of type int initialized to Structure of the Methods As described by the UML Class Diagram above, your CheckingAccount class must have the following methods: - a public method named debit that takes an int argument and returns a boolean - a public method named setFee that takes an int and returns nothing - a public method named getFee that takes no arguments and returns an int - a public method named applyinterest that takes no arguments and returns nothing - a public method named account Info that takes no arguments and returns a string Note that three of these methods are defined as abstract in the BankAccount base class. You will be overriding and implementing these methods in this CheckingAccount concrete derived class. Behavior of the Methods - The debit method should subtract the argument amount from the balance. The debit method should always return true. - The setFee method should store the argument amount in the overdraftFee field. - The getFee method should return the value stored in the overdraftFee field. - The applyInterest method should compute the interest amount and add this amount to the balance, but only if the balance is greater than . - The accountinfo method will return a string formatted exactly like this: TypeofAccountAccountIDCurrentBalanceInterestrateOverdraftFeeChecking:1111222233334444:$123.45:1.508:$20.00 Additional Information BankAccount Class Copy and paste your BankAccount class code from your Bank Account (Individual Assignment) into the BankAccount. Java file in the editor below. All Bank Accounts 1. All accounts have balance, credit and debit amounts, and fees stored and passed as a number of pennies (int). 2. All debit amounts will be subtracted from the balance, and all credit amounts will be added to the balance. 3. All bank accounts have a non-negative interest rate ( 0.02 would be a 2% interest rate). 4. When applying interest, interest amount is calculated by multiplying the balance by the interest rate. 5. When applying interest, interest amount is always added to the balance, and any fractional part will be rounded down. 6. Interest will not be applied to any Savings or Checking account with a balance of zero or less. 7. Debit methods will return false if the transaction cannot be made because of insufficient balance or insufficient credit limit. Otherwise they will return true. 8. The credit method will always return true. Checking Accounts 1. A CheckingAccount can have a negative balance. - The debit method for the CheckingAccount will always return true. 2. Any CheckingAccount debit that ends with a negative balance will incur an overdraftFee (i.e. the overdraftFee amount will be subtracted from the balance). A CheckingAccount debit will always succeed. 3. Interest will not be applied to a CheckingAccountwith a negative balance. 17:Logic Test 10 Given a CheckingAccount(ca), with balance of 0, after ca.setFee(2000) and ca.debit(3000), getBalance should return -5000 Test feedback 23:Logic Test 16 Given a new CheckingAccount(ca), after ca.setFee(2000) and ca.setAccountID("1111-2222-3333-4444") and ca.credit(1000) and ca.setInterestRate( 0.025), accountInfo should return a correctly formatted String java.util.IllegalformatConversionException:f!=java.lang.Integer 24:Logic Test 17 Given a new CheckingAccount(ca), after ca.setFee(1000) and ca.setAccountID("1234-5678-9876-5432") and ca.credit(9876) and ca.setInterestRate( 0.123), accountinfo should return a correctly formatted String java.util.IllegalFormatConversionException:f!=java.lang.Integer 25:Logic Test 18 Given a new CheckingAccount(ca), after ca.setFee(1500) and ca.setAccountID("1357-2468-0000-9999") and ca.credit(123456) and ca.setInterestRate(0.015), accountInfo should return a correctly formatted String java.util. IllegalFormatConversionException: f != java.lang. Integer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

Explain how a transistor could be used as a switch?

Answered: 1 week ago