Debit that withdraws money from an account

Assignment Help Business Management
Reference no: EM132143130

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

Reference no: EM132143130

Questions Cloud

Is pursuing this campaign smart investment for droga : Is pursuing this campaign a smart investment for Droga 5 - and for the proposed partners Random House, Roc Nation, and Microsoft?
How projects are planned and executed in scrum : There are a number of frameworks that have been used for agile development and project management. The purpose of this assignment is to discuss how projects.
Examine a code of ethics for a professional organization : Examine a code of ethics for a professional organization, business, or government agency, and write a critique of it.
Explain what is meant by sufficiency of the consideration : Explain what is meant by the "sufficiency of the consideration". Make sure to provide examples of what would not be sufficient consideration, and why.
Debit that withdraws money from an account : 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.
What percent safety margin of stock is being carried : What percent safety margin of stock is being carried?
Describe threats and vulnerabilities : Describe threats and vulnerabilities and how to address them using a business impact analysis.
How you would correct the issue : One criticism of electronic ballots for elections is that while intuitive for younger voters who are familiar with using a mouse to point and click.
All organizations are quick to adopt these methods : Given the benefits of Continuous Improvement techniques like Six Sigma and Lean, why is it that not all organizations are quick to adopt these methods?

Reviews

Write a Review

Business Management Questions & Answers

  Caselet on michael porter’s value chain management

The assignment in management is a two part assignment dealing 1.Theory of function of management. 2. Operations and Controlling.

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. Due to increase in the preference for light beer drinkers, Chris Prangel wants to introduce light beer version in Mountain Man. An analysis into the la..

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. An analysis into the launch of Mountain Man Light over the present Mountain Man Lager.

  Analysis of the case using the doing ethics technique

Analysis of the case using the Doing Ethics Technique (DET). Analysis of the ethical issue(s) from the perspective of an ICT professional, using the ACS Code of  Conduct and properly relating clauses from the ACS Code of Conduct to the ethical issue.

  Affiliations and partnerships

Affiliations and partnerships are frequently used to reach a larger local audience? Which options stand to avail for the Hotel manager and what problems do these pose.

  Innovation-friendly regulations

What influence (if any) can organizations exercise to encourage ‘innovation-friendly' regulations?

  Effect of regional and corporate cultural issues

Present your findings as a group powerpoint with an audio file. In addition individually write up your own conclusions as to the effects of regional cultural issues on the corporate organisational culture of this multinational company as it conducts ..

  Structure of business plan

This assignment shows a structure of business plan. The task is to write a business plane about a Diet Shop.

  Identify the purposes of different types of organisations

Identify the purposes of different types of organisations.

  Entrepreneur case study for analysis

Entrepreneur Case Study for Analysis. Analyze Robin Wolaner's suitability to be an entrepreneur

  Forecasting and business analysis

This problem requires you to apply your cross-sectional analysis skills to a real cross-sectional data set with the goal of answering a specific research question.

  Educational instructional leadership

Prepare a major handout on the key principles of instructional leadership

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd