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
List the steps to identify address or link window on a phone​
Law Incorporation [45]

Answer: this is how

Explanation: if you are on your phone and a link pops up if it is blue then it is able to be clicked but if it is not blue you can simply copy and paste the link into your web browser.

7 0
3 years ago
Multidimensional arrays can be stored in row major order, as in C , or in column major order, as in Fortran. Develop the access
larisa86 [58]

Answer:

Access functions explained below

Explanation:

Access functions for Three Dimensional Arrays:

Let M, N and P refer to the size of the 1st 2nd and 3rd dimensions respectively.

Element_Size is the memory size the array element.

Generic access functions for Row Major:

If character data is used then Element_Size is 1.

For i=0 to P do

For i=0 to N do

  For i=0 to M do

     Address_of _array[i, j, k] = address_of_array[0,0,0] + (i * P + j * N + k) * Element_Size

    Store data into the Address_of _array[i, j, k]

    Or

  Display data from Address_of _array[i, j, k]

end

end

end        

Generic access function for Column Major:

if For i=0 to M do

For i=0 to N do

  For i=0 to P do

     Address_of _array[i, j, k] = address_of_array[0,0,0] + (i * M + j * N + k) * Element_Size

    Store data into the Address_of _array[i, j, k]

    Or

  Display data from Address_of _array[i, j, k]

end

end

end      

3 0
4 years ago
Jenna updated her status on a social network regarding her upcoming vacation. What information should Jenna not provide when upd
juin [17]

D. her opinions on social issues

4 0
3 years ago
What is the use of router ?​
iren [92.7K]

Answer:

A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet. Data sent through the internet, such as a web page or email, is in the form of data packets.

Explanation:

6 0
3 years ago
What is the term for a collection of related html documents located on a host computer on the internet?
alexandr402 [8]

Answer:

A website

Explanation:

The web pages are linked together by hyperlinks. Web pages are created using Hypertext Markup Language (HTML), which is the authoring language used to create documents on the World Wide Web.

3 0
3 years ago
Other questions:
  • A circuit has a resistance of 300 ohm and a current of 0.024 A. What is the voltage in the circuit?
    12·1 answer
  • Can someone help me? Thanks.
    10·1 answer
  • What device copies system files
    14·1 answer
  • Explain the difference between the term graphic communication and printing
    7·1 answer
  • Fredrick wants to revise an employee policy. If he wants to inform all of the employees of the change, what type of document wil
    10·2 answers
  • What happens if you never confirm your facebook account?
    8·1 answer
  • I - For any two points on the Internet, there exists only one path between the two points II - Routing on the Internet is fault
    12·1 answer
  • Write regular expressions for the following languages:
    5·1 answer
  • Narrate an incident from the experience of a 14 year old girl which brings out the message: " Never leave till tomorrow what you
    10·1 answer
  • Name any two objectives of a business​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!