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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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