1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
STatiana [176]
3 years ago
9

Write a Java class called BankAccount (Parts of the code is given below), which has two private fields: name (String) and balanc

e (double), and three methods: deposit(double amount), withdraw(double amount) and toString(). Write the necessary constructors, accessor methods and mutator methods. The deposit() method adds the amount to the account causing the current balance to increase, withdraw() method subtracts the amount causing the current balance to decrease and toString() method should return the name and the current balance separated by a comma. For example, if you print out the object with name Jake and balance 40.0 then it should print:

Computers and Technology
1 answer:
NemiM [27]3 years ago
3 0

Answer:

Here is the Bank Account class:

public class Bank Account {   //class definition

   private String name;  //private String type field to hold name

   private double balance;    // private double type field to hold balance

    public Bank Account(String name, double balance) {  // parameter constructor that takes

//this keyword is used to refer to the data members name and balance and to avoid confusion between name, balance private member fields and constructor arguments name, balance

 this.name = name;  

 this.balance = balance;  }    

   public void deposit(double amount) {   //method to deposit amount

               balance = balance + amount;     }    // adds the amount to the account causing the current balance to increase

   public void withdraw(double amount) {  //method to withdraw amount

 balance = balance - amount;   }   //subtracts the amount causing the current balance to decrease

    public String toString() {  // to display the name and current balance

              return name + " , $" + balance; }  } //returns the name and the current balance separated by a comma and dollar

Explanation:

The explanation is provided in the attached document due to some errors in uploading the answer.

You might be interested in
Help me with this please​
slava [35]
<h2>sorry...</h2>

I don't know the answer

3 0
3 years ago
Read 2 more answers
Which of the following is an acrostic
Darina [25.2K]
There is no option........................................
5 0
4 years ago
2 4.1.2 Quiz: Information Systems and Business Planning
Delicious77 [7]

Answer:

Option D

Explanation:

Complete question

A management information system is typically used by _____.

A. all levels of employees

B. company executives

C. upper-level managers

D. middle-level managers

Solution

A management information system is typically used by middle-level managers

Option D is the correct answer

Management information system (MIS) helps the middle managers to control the work across the various teams of organization.

5 0
3 years ago
What permissions are needed in order to use a work online that is in the public domain?
Maurinko [17]
<h2 /><h2>⇒Written  \: permission  \: from \\  the  \: creator</h2>

The term “public domain” refers to creative materials that are not protected by intellectual property laws such as copyright, trademark, or patent laws. ... Anyone can use a public domain work without obtaining permission, but no one can ever own it.

5 0
3 years ago
Powerpoint assumes that the first slide in a new presentation is the
fomenos
Powerpoint assumes that the first slide in a new presentation is the title slide
5 0
3 years ago
Other questions:
  • Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entere
    15·1 answer
  • Define the term e-learning​
    5·2 answers
  • Which view in file explorer can use to sort files by column heading
    8·1 answer
  • Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
    11·1 answer
  • To select an unselected text object, press [____], click the text object, and then release [____].
    8·1 answer
  • Which of the following is not a responsibility of a member of society?
    14·1 answer
  • In 4-bit two's complement representation, what is the binary encoding of the number -5?
    8·1 answer
  • Alex builds a 1 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
    6·1 answer
  • What are the impacts of mobile phone?as well as the positive and negative impacts?​
    5·1 answer
  • Cidr simplifies how routers and other network devices need to think about the parts of an ip address, but it also allows for mor
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!