Write a class called checkingaccount

Assignment Help Basic Computer Science
Reference no: EM13308084

Write a class called CheckingAccount that has the following fields and methods.
Fields
double balance
Methods
getBalance() - returns the balance as a double
withdraw(double amount) - withdraws amount if possible; otherwise, prints a message to the user saying, "Cannot complete withdraw: insufficient funds"
deposit(double amount) - adds the deposit amount to the balance
a constructor that takes an initial amount and initializes the balancefield.


public class Lab11Driver
{
public static void main(String[] args)
{
// Creates an account with a balance of $450.00
CheckingAccount c1=new CheckingAccount(450.00);
// Use the "getter" function to find the initial balance
double balance=c1.getBalance();
// Print it out
System.out.println("Your initial balance is: "+balance);
//Deposit $25.00
balance=c1.deposit(25.00);
// Should be $475.00
System.out.println("Your new balance is: "+balance);
//Withdraw $100.00
balance=c1.withdraw(100.00);
// Should be $375.00
System.out.println("Your new balance is: "+balance);
// Withdraw more than in the account
balance=c1.withdraw(9001.00);
//Should print -1, or some kind of error message
System.out.println("Your balance is: "+balance);
}


}

 

Reference no: EM13308084

Questions Cloud

It averaging business advantage at a management level. : IT leveraging business advantage at a management level.
Write a function which has this exact signature : however. As an example, if the main() function were: int main() { double x[] = {2,4,4,4,5,5,7,-9}; cout
Paper on low income housing or subsidized housing in urban : This is a paper on low income housing or subsidized housing in urban economics.The paper must be atleastten pages long (double spaced if you want), and contain footnotes.
Calculates the cost of a mortgage : Write a class called Mortgage that calculates the cost of a mortgage. Prompt the user to enter the principal amount, the term in years, and the interest rate per year.
Write a class called checkingaccount : Write a class called CheckingAccount that has the following fields and methods.
How does the nature of the boundary layer affect lift : sitting on the deck one evening. watching for that pesky bunny, jon and his brother see a twig floating down from an aspen tree. (wait - os that a bunny) they wonder just what the boundary layer looks like on the twig.
Business communication : BUSINESS COMMUNICATION
What is the horizontal distance the ball travels : A ball is thrown horizontally off the top of a building with a height of h=22.5m. What is the horizontal distance the ball travels before it hits the ground
State multiprogramming and multiprocessing for same problems : It is stated that multiprogramming and multiprocessing present the same problems, with respect to concurrency. This is true as far as it goes. However, cite two differences in terms of concurrency between multiprogramming and multiprocessing.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write a program in python shell

Write a program in python shell. Convert inches into yards, feet, and inches. This time, use a variable to store the number of inches. You may use more than one variable.

  Explain the differences between server-side and client

3. Logic is a key factor in laying out the processes for programming a game/application/website. Explain why logic is an important part of OOP.

  Information security problem or issue in organisation

Illustrate how the work breakdown structure would identify and plan an information security problem or issue in the organisation.

  Research various types of hard drives available from online

Research the various types of hard drives available from online and/or local retail computer stores.Make a chart of several different brands or models of 1 TB desktop hard drives.

  How fast can a telephone channel carry data

If a telephone channel's signal-to-noise ratio is 1000, how fast can a telephone channel carry data?

  Why does this type of delegation make sense

Which is preferable, to delegate permissions to an individual or to a group? Why does this type of delegation make sense?

  Explain data by state of computer-s electrical switches

Differentiate between computer data represented by the state of computer's electrical switches and meaningful information which is displayed to user.

  Current standards sufficient to protect privacy

What is the right of privacy, and what is the basis for protecting personal privacy under the law and are current standards sufficient to protect privacy?

  Full description of the new system

Full description of the new system, a description of its components, and the benefit it will provide to Riordan

  How to break 4 digit numbers to two parts in java

Help me how to break 4 digit numbers to two parts (2 digits and 2 digits) in java

  Write name of storage location involved in the code

Recognize each dependency by type; write the two instructions involved; recognize which instruction is dependent; and name storage location involved.

  Describe the five forces model

Describe the Five Forces Model. What role does the Five Forces Model play in decision making? Define a database management system and discuss each of the five important software components of a database management system.

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