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

  What interference would the primary service cause in service

What interference would the primary service cause in the secondary service. That is what would the signal-to-interference ratio (SIR) of the secondary user be?

  Write an application named collegelist

Write an application named CollegeList that declares an array of four "regular" CollegeEmployees, three Faculty, and seven Students.

  Analyze your findings about one identified thief

Analyze your findings about one identified thief. How can you learn from your chosen thief to acknowledge and recognize the motives and behavioral indicators that someone might be spying against the company you work for?

  What would you recommend as a remedy to the drawback

Suppose a large office building has ESS WLAN for the office users. As a network engineer, you are asked to identify the drawbacks of the ESS WLAN.

  Maps the province names to the names of province

Given a variable , province_premier, that is associated with a dictionary that maps the province names to the names of province premiers, associate.

  Create an erd diagram and a logical diagram

Create an ERD diagram and a Logical diagram for a company database

  Outline a plan for the development of an addressing and

write a three to four 3-4 page paper in which you1 outline a plan for the development of an addressing and naming model

  Provides a method for data to be transferred between systems

XML provides a method for data to be transferred between systems. Specify at least three components of an XML document.

  Create a data model that site needs to support its business

Create a data model that the site needs to support its business process. Include entities to show what types of information the site needs.

  Design a to perform various matrix operations

Design a to perform various matrix operations. class A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position.

  Oracle security guidelines

Visit http://www.oracle.comand search for "Oracle Security Guidelines". Read articles at three of the links you find and summarize them.Remember to cite your references using APA format.

  Suppose that the toolbar is named tbrcurrent

at last if the index of the button is two (2), then call the procedure named ExitSolution. Assume that the toolbar is named tbrCurrent.

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