Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code in Java :SavingsAccount.java public class SavingsAccount extends BankAccount { public boolean debit(int pennies) { if (pennies > balance) { return false; } balance

My code in Java

:SavingsAccount.java

public class SavingsAccount extends BankAccount {

public boolean debit(int pennies) { if (pennies > balance) { return false; } balance -= pennies; return true; } public void applyInterest() { if (balance > 0) { double interestAmount = balance * interestRate; balance += (int) interestAmount; } }

public String accountInfo() { return "Type of Account : Savings" + " " + "Account ID : " + accountID + " " + "Current Balance : $" + balance / 100 + "." + balance % 100 + " " + "Interest rate : " + interestRate + "%"; } }

:BankAccount.java

public abstract class BankAccount { protected String accountID; protected double interestRate; protected int balance; public BankAccount() { accountID = "0000-0000-0000-0000"; interestRate = 0.0; balance = 0; } public boolean credit(int pennies) { 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(); }

image text in transcribed

Can anyone fix the problem that showing in pic! I have to get interest rate correct to get the points

Given a new SavingsAccount (sa), after sa.setAccountID("1111-2222-3333-4444") and sa.credit(1000) and sa.setinterestRate(0.025), accountInfo should return a correctly formatted String 19:Logic Test 14 Given a new SavingsAccount (sa), after sa.setAccountID("1234-5678-9876-5432") and sa.credit(9876) and sa.setInterestRate(0.123), accountInfo should return a correctly formatted String

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

Students also viewed these Databases questions

Question

How is a C corporation subject to double taxation?

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago