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]
2 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]2 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
Which of the following can you use to attach external hardware devices to a computer?
Genrish500 [490]

The answer is c that what a lot of people use☻

5 0
2 years ago
Read 2 more answers
The range of a finite nonempty set of $n$ real numbers $S$ is defined as the difference between the largest and smallest element
-Dominant- [34]

Answer: Hello your question is poorly written attached below is the well written question

answer:

a) Determine ( compute ) the difference between the max and minimum value. determine the Min and max values using 1.5n comparisons

  time efficiency = θ( n )

b) A(n-1) - A(0)

  time efficiency = θ( 1 )

Explanation:

a) An unsorted array

To find the maximum and minimum values scan the array of elements , then determine ( compute ) the difference between the max and minimum value. to determine the range. Alternatively determine the Min and max values using 1.5n comparisons

Algorithm's time efficiency = θ( n )

b) A sorted array

To determine the range, we will determine the difference between the first and last element i.e. A(n-1) - A(0)

time efficiency = θ( 1 )

7 0
2 years ago
Create a single line comment that says ""Print results to screen""
levacccp [35]

Answer:

//""Print results to screen""

Explanation:

In c,c++,java,javascript // is used for the single line comment.

syntax:- // comment.

Whatever text that is followed after // is commented means this line will not get executed by the compiler.

Comments are used to explain the code to other person who is working on the code or trying to understand that code.

6 0
3 years ago
Select statements about Multiprocessors that are FALSE. a. Asymmetric multiprocessors are a popular form of tightly coupled arch
Inessa [10]

Answer:

The statement about Multiprocessors that is FALSE is:

a. Asymmetric multiprocessors are a popular form of tightly coupled architecture

Explanation:

Symmetric multiprocessors house two or more identical processors sharing a single main memory.  The multiprocessors are tightly coupled, and all of them can access all the connected devices without any preferential treatment of one over the others.  This is unlike asymmetric multiprocessors that do not share a single main memory.   Instead, they have distributed memories.

4 0
2 years ago
How to remove special formatting from a table in word.
ch4aika [34]

Answer:

Clear Format

Explanation:

7 0
2 years ago
Other questions:
  • Theresa is a certified teacher. She just had a baby and would like to stay home, but still wants to teach. Which career would be
    11·2 answers
  • What is the opening page of a website called?
    9·2 answers
  • On an open book test, Anna was asked to predict how American laws may affect the Mexican way of life if the US Constitution was
    15·1 answer
  • The best place to start when you are looking for information about a device or an application is the ____ of the company that ma
    14·1 answer
  • Does any one here play destiny on xbox one
    12·1 answer
  • You can use a(n) to call a function in response to an event?
    14·1 answer
  • How does leadership play a role in IT management? How does leadership need to be aligned to the company’s goals for IT managemen
    9·1 answer
  • If someone wanted to talk to a financial institution representative in person they would need to _____.
    5·1 answer
  • Consider the following code.
    7·2 answers
  • What is computer software?​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!