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
Which value can be entered to cause the following code segment to display the message "That number is acceptable."
AnnZ [28]

Answer:

We can give the any  integer value between 10 to 100 then it display the message "That number is acceptable."

Explanation:

In the given code the "number" variable takes an user input via cin .After taking user input it check the condition of if block that the user input is between the range of 10 to 100 .if this condition is true then the statement of if block will be executed i.e  That number is acceptable otherwise else block will be executed That number is not acceptable.

following are the code in c++

#include <iostream> // header file

using namespace std;

int main() // main

{  

   int number; // variable

cin >> number; // taking input

if (number > 10 && number < 100) // if block

cout << "That number is acceptable.";

else

cout << "That number is not acceptable.";

return 0;

}

Output:

66

That number is acceptable.

456

That number is not acceptable.

8 0
4 years ago
Define cyber law and cyber crime with examples.​
kifflom [539]

Answer:

Cyber crime is unlawful acts where the computer is either a tool or target or both. An example of such would be theft, fraud, forgery, etc. Cyberlaw on the other hand encompasses cybercrime.

4 0
3 years ago
What is a what if analysis in Excel example?
Sergio039 [100]

Answer:

What-If Analysis in Excel allows you to try out different values (scenarios) for formulas. The following example helps you master what-if analysis quickly and easily.

Assume you own a book store and have 100 books in storage. You sell a certain % for the highest price of $50 and a certain % for the lower price of $20.

(i really hope this is what u needed)

4 0
3 years ago
A technician is tasked with installing the Windows OS on a Mac OS computer so that the computer can boot to either the Mac OS or
nata0808 [166]

Answer:

Key chain because it easier

Explanation:

4 0
2 years ago
Which of the statements below describe guidelines for effective presentation layouts? (multiple choice)
____ [38]
Putting as much information as possible on a slide is wrong because sometimes, that will create a messy presentation. A messy presentation can become unreadable and if your information is unreadable, it is not effective. Similarly, you do not want to use a font color that blends in with the background. A yellow font on a yellow background could clash negatively or make your information seem to disappear into the background completely. Presenting this on a screen would make it almost impossible to see anything of what you wrote. This would be ineffective, as well. Using the largest font size possible is also not a very good idea because it's going to be too big. It will fill up the entire screen and make everything messy seeming, overwhelming to look at, or unreadable. Another ineffective decision. 

Now, although using a maximum of two fonts on a slide is important, this does not specify the fonts which you should NOT use. There are many unreadable fonts that create a messy an ineffective presentation, and just getting to choose any two of them isn't very specific.

The correct answer would be to use a consistent color scheme. Sometimes the most effective presentations are simple, yet well put together. 
8 0
3 years ago
Read 2 more answers
Other questions:
  • What’s of the following can be used to visually represent information similar to diagrams format painter Helens smart are a clip
    8·1 answer
  • ________ symbol is used in the "Advanced" section of the time range picker to round down to nearest unit of specified time.
    8·1 answer
  • Write code that inserts useritems into the output string stream itemsoss until the user enters "exit". each item should be follo
    15·1 answer
  • To give text an outline, you can use which command?
    15·1 answer
  • Write a C++ program that allows the user to enter double values. Display one of two messages: "The first number you entered is l
    9·1 answer
  • An online service allows users to integrate their phonebook with their social media profiles and stores it on the cloud. The pho
    12·1 answer
  • A _____ attack is designed to generate a lot of activity on a network by flooding it with useless trafficenough traffic to overw
    14·2 answers
  • Which of the following is a good conductor of electricity and heat?
    13·2 answers
  • You are an IT manager at Gigantic Life Insurance. You have a new desktop support person starting today whose experience is limit
    10·1 answer
  • What is the difference between packaged and tailored software ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!