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.:- M93130595
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Business Management

Define job description and job specification and describe

Define job description and job specification and describe how they are used in management

Why should companies furnish her staff or employees with

Why should companies furnish her staff or employees with floating holidays?

Employees at many successful companies start the day by

Employees at many successful companies start the day by checking the economic forecast. Patagonia's Ventura, California, employees start the day by checking the surf forecast. The outdoor clothing company encourages its ...

You are the production department manager at kibby and

You are the Production Department manager at Kibby and Strand, and last month there were complaints from customers that the quality of the products shipped to them was lacking. Some stitching on T-shirts was weak and the ...

The balanced scoreboard approach has gained popularity in

The balanced scoreboard approach has gained popularity in recent years. What is this approach and how does it integrate strategic and operational control?

Why do you think grafton furniture might be keen to

Why do you think Grafton furniture might be keen to increase steven Grafton's span of control.

Discuss the different characteristics of a group goal

Discuss the different characteristics of a group (goal orientation, interdependent, interpersonal interaction, perception of membership, structured relations, mutual influence, and individual motivation) and give example ...

This is from my training and development course1 how might

This is from my training and development course 1) How might course design differ for baby boomers compared to Gen Xers? 2) What could be done to increase the likelihood of transfer of training if the work environment co ...

Auburn creed i believe that this is a practical world and

Auburn Creed: I believe that this is a practical world and that I can count only on what I earn. Therefore, I believe in work, hard work. I believe in education, which gives me the knowledge to work wisely and trains my ...

Someone installed malware on carlos computer it records his

Someone installed malware on Carlo's computer. It records his purchases on Amazon and other sites and reports them to an agency that sends Carlo advertisements for other products. This is not a big deal. Do you agree? Ex ...

  • 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