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

  Web forms controls

Using Web Forms controls,create a Web application to include a TextBox object,a Button object,and a ListBox object. Allow the user to input values into the TextBox.Use those values to populate the ListBox object.

  Recognize interface metaphor to use for conceptual design

For conceptual design (architectural or high-level), recognize the interface metaphor to use, interaction type(s) to employ, and interface type(s) to follow. For each of these, make sure to describe why you select what you did.

  The tblmaginfo table contains three fields

The tblMagInfo table contains three fields. The Code and Cost fields are numeric. The Magazine field contains text. The dataset's name is MagsDataSet.

  Decreasing risk of malicious attacks in personal systems

Security budgets is devoted to decreasing risk of malicious attacks. What threats are you aware of when it comes to the personal systems and systems at job

  Create a table consisting of each integer and its square

Write the MATLAB statements required to calculate and print out the squares of al the even integers between 0 and 50. Create a table consisting of each integer and its square, with appropriate labels over each column. I MUST use a while loop but I..

  Describe how the deadlocks can be resolved

give at least two real life examples ( not related to a computer system invironment) of each of these concepts:deadlock, starvation, and race. describe how the deadlocks can be resolved.

  Write a program that can be used to assign seats

Write a program that can be used to assign seats for a commcommercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class, rows 3 to 7 are business class, and rows 8 to 13 are economy class

  Browser immediately checks data is correct. true or false

When a user enters data into a form then submits the form (typically, by clicking the Submit button), the browser immediately checks that the data is correct. True or False

  Mini case: k-mart

Mini Case: K-Mart

  Bob is stationed as a spy in cyberia for a week

Bob is stationed as a spy in Cyberia for a week and wants to prove everyday of this week that he is alive and has not been captured. He has chosen a secret random

  Draw a possible class diagram,uml diagram for the system

Ship A has two instruments, which provide digital information for navigation: (1) A global positioning system (GPS) measures the position and velocity of Ship A.

  Takes a string as input and returns a string

Write a method that takes a String as input and returns a String containing the middle character of the String if the length of that String is odd.

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