Display the name and current balance for this object

Assignment Help Computer Engineering
Reference no: EM132200499

Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0.

The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the current balance to decrease and toString() method returns account name and the current balance separated by a comma.

For example if name is Jake and balance is 40.0 it should return

Jake, $40.00

public class BankAccount {

private String name;

public void deposit(double amount) {

balance = balance + amount;

}

public void withdraw(double amount) {

}

}

Write a client program called BankAccountClient that creates a BankAccount object called B1 and assigns "John" to its name field and 1000 to balance field.

Call the deposit method to deposit 500 to this account and call the display method to display the current balance. Then, withdraw 300 from this account and print the object using println.

Create another object called B2 without passing parameters and display the name and current balance for this object.

Reference no: EM132200499

Questions Cloud

Analyze a paragraph for readability using the coleman-liau : Write a Java console application that analyzes a paragraph for readability using the Coleman-Liau index.
Write a java class using generics : You are to write a Java Class using Generics. This class is to be a Double Linked List container for holding other objects which are comparable.
What is the mac of fluoride in drinking water : What is the MAC of fluoride in drinking water? How does fluoride gets into drinking water?What are the health effects of overexposure to fluoride?
Extremely hot flame when it burns in pure oxygen : Acetylene gas (C2H2) used in welding, produces an extremely hot flame when it burns in pure oxygen according to the reaction
Display the name and current balance for this object : Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double).
Write a java for loop that iterates an array of type double : Write a Java for loop that iterates an array of type double named dArray, of any size, and replaces each element with its squareroot.
Balance the ions and complete the circuit : A salt bridge is used in voltaic cells to balance the ions and complete the circuit. Describe this scenario. (hint;use a diagram)
What are the kinetic theory assumptions about ideal gases : What are the kinetic theory assumptions about ideal gases. State the ideal gas equation.
Types of possible transitions that can occur : Draw the energy level diagram of Hydrogen showing all the types of possible transitions that can occur. Show the IR,UV,VL.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program to generate a series of pseudo random number

You will write a program to generate a series of pseudo random numbers, using a linear feedback shift register method. You will start with an arbitrary number (not zero) x with a representation in n bits.

  Create a blank sheet where you can enter your circuit

Create a blank sheet where you can enter your circuit. The "iDoc circuit should output according to the following formula.

  How do you think the hacker got into the computer to set

a hacker had installed a program on the computer that made it automatically send out tons of spam email without the computer owner's knowledge

  How many fragments are generated

Consider sending a 4800-byte IP datagram into a link that has an MTU of 820 bytes.

  How your team has decided to address the issues

Discuss issues encountered in the work and how your team has decided to address the issues. Prepare a functional prototype of your application.

  Which jobs are possibly to change

Where would the computing profession be in 10 years, 25 years, 50 years? Will it be different than it is today? In what ways? Which jobs are likely to change.

  Describe briefly four built-in functions in sql with example

List and describe briefly 4 Built-in functions (aggregate functions) in SQL with examples. Propose a suitable solution to overcome anomalies identified in 3(a).

  What criteria does your new strategy perform better or worse

Under what criteria does your new strategy perform better or worse than the strategy from this chapter?

  How can you generate a list of such files

The tar command on one system can't accept absolute pathnames longer than 100 characters. How can you generate a list of such files?

  Explore the issue of truthfulness in the stable matching

Explore the issue of truthfulness in the Stable Matching Problem and specifically in the Gale-Shapley algorithm.

  Assingment 1 social media crm historyusing your book and

assingment 1 social media crm historyusing your book and many outside resources research the history of the use of

  Study the variation in chicagos temperature

If the temperature never increased, then report that. Give a O(n log n) algorithm for this task.

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