Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you should modify only the User.java file. Make sure that the InsufficientFundsException.java file is in the same folder as your User.java File.

For this assignment, you should modify only the User.java file. Make sure that the InsufficientFundsException.java file is in the same folder as your User.java File. To test this program you will need to create your own "main" function which can import the User, create an instance and call its methods. One of the methods will throw an exception in a particular circumstance. For this assignment, to throw the Exceptions you will use "throw new InsufficientFundsException();" Follow the TODOs and the documentation in the User.java file to complete this assignment.

User.java.file

public class User { // Class Attributes private String username; private double balance; /*** * Default Constructor * Should set all values to their defaults * Strings should be set to "unknown" * balance should start at $0 */ public User() { // TODO 1 IMPLEMENT THIS METHOD } /*** * Constructor * the class attributes should be set to the values passed in by the method parameters * * The remaining attributes should be set to their defaults: * balance should start at $0 * * @param: username */ public User(String username) { // TODO 2 IMPLEMENT THIS METHOD } /*** * * @return the username */ public String getUserName() { // TODO 3 IMPLEMENT THIS METHOD return ""; } /*** * * @return current balance amount as double */ public double getBalance() { // TODO 4 IMPLEMENT THIS METHOD return 0.0; } /*** * * @return current balance amount as formatted string with $ and 2 decimal point * precision */ public String getFormattedBalance() { // TODO 5 IMPLEMENT THIS METHOD return ""; } /*** * This method should add a deposit amount to the balance * * @param deposit */ public void deposit(double deposit) { // TODO 6 IMPLEMENT THIS METHOD } /*** * This method should detract a withdrawal from the balance * * @param withdrawal * * @throws InsufficientFundsException if the withdrawal will put the current * balance below $0 */ public void withdrawal(double withdrawal) throws InsufficientFundsException { // TODO 7 IMPLEMENT THIS METHOD } /*** * * Given a rate and a number of months, calculate the projected balance. * * Example Balance = $100 * Months = 4 * Rate = 0.01 (1%) * * After 1 Month Balance = $101 (100 + (100 * 0.01)) * After 2 Months Balance = $102.01 (101 + (101 * 0.01)) * After 3 Months Balance = $103.0301 (102.01 + (102.01 * 0.01)) * After 4 Months Balance = $104.060401 (103.0301 + (103.0301 * 0.01)) * * return 104.060401 * * @param rate (Will always be positive) * @param months (Will always be greater than 1) * @return estimated balance after "months" months of cumulative interest at * rate "rate" */ public double projectedBalance(double rate, int months) { // TODO 8 IMPLEMENT THIS METHOD return 0.0; } }

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899