Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Business Management Expert

Problem 1. Modify class Account to provide a method called debit that withdraws money from an Account. Ensure that the debit amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the method should print a message indicating "Debit amount exceeded account balance." class AccountTest to test method debit. You can find the Account class template on Canvas.

Note:  Refer to "CSC110_Chp3-Classes-v3.ppt" Slides 64-70 to see a sample code

Below is the Sample Output:

account1 balance: $50.00

account2 balance: $0.00

Enter withdrawal amount for account1: 25.67

subtracting 25.67 from account1 balance

account1 balance: $24.33

account2 balance: $0.00

Enter withdrawal amount for account2: 10.00

subtracting 10.00 from account2 balance

Debit amount exceeded account balance.

account1 balance: $24.33

account2 balance: $0.00

The code for the account class you need to modify can be found below. You will need to driver class in order to create objects of the class and test them!

Note:  Refer to "CSC110_Chp3-Classes-v3.ppt" Slides 64-70 to see a sample code

/**

* Lab 5: Account.java

* Last Edited 10/18/2016 by Author Name

* Compilation: javac Account.java

*

* Account class with a constructor to initialize

* instance variable balance.

*

* -- Methods --

* Constructor:

*  public Account(double initialBalance)

*

*  constructs a Account object and sets balance of

*  the account to initialBalance

*

*  sample use:

*  Account myAccount = new Account(500.0);

*  will account object with balance 500;

*

* credit method:

*  public void credit( double amount);

*  

*  will increase the balance of the account by amount

*

* getBalance method:

*  public double getBalance();

*   

*  returns the balance of the account as a double

*/

 

public class Account

{  

  private double balance; // instance variable that stores the balance

 

  // constructor 

  public Account( double initialBalance )

  {

     // validate that initialBalance is greater than 0.0;

     // if it is not, balance is initialized to the default value 0.0

     if ( initialBalance > 0.0 )

        balance = initialBalance;

  } // end Account constructor

 

  // credit (add) an amount to the account

  public void credit( double amount )

  {     

     balance = balance + amount; // add amount to balance

  } // end method credit

 

  /* write code to declare method debit */

 

  // return the account balance

  public double getBalance()

  {

     return balance; // gives the value of balance to the calling method

  } // end method getBalance

} // end class Account

Business Management, Management Studies

  • Category:- Business Management
  • Reference No.:- M93127818
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Business Management

Httpsmycoursesutrgvedubbcswebdavpid-4000856-dt-content-rid-5

https://mycourses.utrgv.edu/bbcswebdav/pid-4000856-dt-content-rid-58365951_1/courses/20783.201910/20783.201910_ImportedContent_20180825101812/51245.201820_ImportedContent_20171218022642/Google%20Inc%20.pdf 1. Evaluate Go ...

What strategies does a company need to develop to become a

What strategies does a company need to develop to become a broad differentiator? In what ways does this provide it with a competitive advantage over either cost leaders? Over differentiators?

Which generic competencies are strong in which of the value

Which generic competencies are strong in which of the value chain elements for Google company and why? (operations, sales& marketing, distribution, service, net profit margin??)

My program needs to create 4 employees id 222333444555 and

My program needs to create 4 employees (ID 222,333,444,555) and then delete one (ID 333) and add a new employee (ID 666). This all works fine, my issue is that once I display the array instead of putting the new employee ...

Outline the capital structure choices open to international

Outline the capital structure choices open to international firms. Give an example using XYZ company.

Suppose that the government gives a 10 per unit subsidy to

Suppose that the government gives a $10 per unit subsidy to sellers of Humbugs. The pre-subsidy price of Humbugs was $50. There are no additional social benefits to encouraging the consumption of Humbugs. If, at the orig ...

Why do companies dislike pure competition would it make

Why do companies dislike pure competition? Would it make economic sense to break up monopolies created by governments? Why or why not?

Questions pertaining to jet bluea give a financial ratio

Questions pertaining to Jet Blue: a. Give a financial ratio analysis for Jet Blue noting good and bad ratios. b. Show Jet Blue's organizational chart found (which I found on Nasdaq (2018). Identify the each chart as well ...

What are the applicable laws about kennamer v ford motor

What are the applicable laws about Kennamer v. Ford motor credit company?

What is the difference between a greenfield investment and

What is the difference between a greenfield investment and an acquisition? Which form of investment is a firm more likely to choose?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As