Question
Java Modify the following code listed below to follow instructions. Instructions: Implement a subclass of BankAccount called BasicAccount whose withdraw method will not withdraw more
Java
Modify the following code listed below to follow instructions. Instructions: Implement a subclass of BankAccount called BasicAccount whose withdraw method will not withdraw more money than is currently in the account.Add a class NumericQuestion. If the response and the expected answer differ by no more than 0.01, accept the response as correct.Add a class AnyCorrectChoiceQuestion that allows multiple correct choices. The respondent should provide any one of the correct choices. The answer string should contain all of the correct choices, separated by spaces. Provide instructions in the question text.Add a class MultiChoiceQuestion. The respondent should provide all correct choices, separated by spaces. Provide instructions in the question text. Provide toString methods for the Question and ChoiceQuestion classes. Provide indented source code. Thanks
Source code:
BankAccount.java public class BankAccount{ private float amount; public BankAccount(float amount) { super(); this.amount = amount; } public float getAmount() { return amount; } public void setAmount(float amount) { this.amount = amount; } @Override public String toString() { return "BankAccount's amount= " + amount + "]"; } } **BasicAccount.java public class BasicAccount extends BankAccount { public BasicAccount(float amount){ super(amount); } public boolean withdraw(float withdrawAmount){ if(withdrawAmount > this.getAmount()) return false; else return true; } } **NumericQuestion.java import java.util.Scanner; public class NumericQuestion{ public static void main(String args[]){ Scanner in = new Scanner(System.in); BasicAccount ba = new BasicAccount(50000); float balanceAmount = ba.getAmount(); while(true){ System.out.println("Enter the maximum withdrawl amount: "); float response = in.nextFloat(); if(Math.abs(response - balanceAmount ) <= 0.01){ System.out.println("Your response is correct"); break; } else System.out.println("Your response is incorrect"); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started