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 down a 200 word paper which explains the distinctions

write down a 200 word paper which explains the distinctions of data and information and in short describe the process a

  Generate email address and identification number

Write a C program so that a user can enter first and last name of students. Generate email address and identification number of the students.

  Write a for loop to increment each element in barray by five

Write a foreach loop to display the contents of bArray. Write a for loop to increment each element in bArray by 5.

  How ip addressing work with dns servers to process a request

Draw a map, labeling every aspect, which represents how IP addressing works with DNS servers to process a request for a web page from your computer that returns the web page. Assume that it takes a few DNS servers to find the IP address.

  Which sort of graphic is the right choice, vector or bitmap

When your boss or client hands you a job, how would you make the determination which type of graphic is the right choice, Vector or Bitmap, in your response, define what parameter you would use and what variable you would have to weigh in your dec..

  What safe equivalent function should they use to prevent

They see the function, strcpy being called. What safe equivalent function should they use to prevent a buffer overflow?

  What are advantages of using the same system-call interface

What are the advantages and disadvantages of using the same system-call interface for manipulating both files and devices?

  Create a presentation in which you insert a title slide

This is for an CIS 105 class- Create a four slide PowerPoint presentation in which you insert a title slide including your name, course, quarter, and professor's name.

  How can you use future-focused thinking to increase success

How can you use future-focused thinking to increase your success trajectories at home, and at work? How will you use future-focused thinking in your career?

  Diploma of information technology design

ICT50115 Diploma of Information Technology Design and implement programs that connect to a database and design and implement programs that use the language facilities to extract, update, and delete data stored in a database

  Distinguish between syntax and semantics

Distinguish between syntax and semantics. Distinguish between a program that the CPU can execute directly and a program that must be translated.

  For benefit of upper management that is non-technical

What edition of Windows 2003 server would you use for your domain controller? If you required four way clustering for Sherrill's Web server, what edition of Windows Server 2003 would you use.

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