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
Schach [20]
3 years ago
11

Create a java class for Bank Accounts with these public String attributes: ownerName, acctNbr and these private double attribute

s: debits, credits. Create a constructor that accepts an owner name and bank account number. It should set debits and credits to 0. Create 3 public methods: addDebit() that accepts a double and adds that amount to the debits addCredit() that accepts a double and adds that amount to the credits getBalance() that returns the credits minus the debits
Computers and Technology
1 answer:
Readme [11.4K]3 years ago
4 0

Answer:

public class BankAccounts

 {

   public String ownerName;

   public String acctNbr;

   private double debits;

   private double credits;

   public BankAccounts(String ownerNm, String acNum)

  {

    debits = 0;

    credits = 0;

    ownerName = ownerNm;

    acctNbr = acNum;

  }

public void addDebit(double debitAmt)

  {

    if(credits > (debits + debitAmt))

      debits = debits + debitAmt;

    else

      System.out.println("Insufficient balance");

}

   public void addCredit(double creditAmt)

  {

    credits = credits + creditAmt;

  }

public double getBalance()

  {

    double balance = 0;

    if((credits - debits) > 0)   // return the value if there is actually some balance left.

      balance = credits - debits;

    return balance;   //returns 0 if credits are lesser or equal to debits

  }

 }

Explanation:

Here class name is <em>BankAccounts </em>which can be used to create a new bank account whenever any user wants to open a bank account. This class will help to track any new account opening, debits and credits operations carried out on that account.

We have a constructor here, which accepts 2 arguments i.e. Bank account <em>Owner Name</em> and <em>Account Number</em>. The constructor also sets the values of <em>debits </em>and <em>credits</em> as 0.

The methods <em>addDebit()</em>, <em>addCredit()</em> and <em>getBalance()</em> help to perform Debit and Credit operations on the account.

NOTE: The method <em>getBalance()</em> returns a positive value only when credits are greater than debits.

The method <em>addDebits()</em> can add debits only as the condition that the credits are greater than the resultant debits.

The code for class <em>BankAccounts</em> is hereby attached.

Download java
You might be interested in
I am wasting 20 points
OverLord2011 [107]
Okkkkkkkkkkkkkkkkkkkkkkk
3 0
3 years ago
Read 2 more answers
Please assist me with these questions - Do not send me links. Issues in opening the links:
Thepotemich [5.8K]

Answer:

15) Halo 2

17) Sims

18) B

19) A

20) B

Explanation:

3 0
3 years ago
Why do you think flowers are a popular topic for macro photography? Do you think you’d like to photograph flowers?
Helen [10]

Why do you think flowers are a popular topic for macro photography?

Macro photography is the part of photography that focuses on taking pictures of very small objects (or small parts of larger objects).  Popular subjects are insects, flowers and small mechanical parts.

Flowers are a very popular subject because they always have lots of interesting details no matter how close you zoom in, like insects.  Flowers however tend to be easier to photograph because they move a lot less than insects.

Do you think you’d like to photograph flowers?

Yes, because it's a new way to look at them.

6 0
3 years ago
Which of the following is considered a period cost in absorption​ costing? A. variable manufacturing overhead costs B. fixed man
sasho [114]
Ccccccccccccccccccccc
5 0
3 years ago
Select the correct answer.
sveticcg [70]

Answer:

D

Explanation:

5 0
4 years ago
Read 2 more answers
Other questions:
  • The photo-sharing site Instagram owed a good deal of its success to filters. What are filters?
    11·2 answers
  • Which one of the following analog VOM ranges would be selected to measure a DC current of 90 milliamps? A. 10mA B. 1.0A C. 10A D
    14·2 answers
  • Eight what makes one character
    14·1 answer
  • A user reports that a workstation is continually rebooting. What can a technician do to stop the rebooting in order to troublesh
    12·1 answer
  • Bcr is an out put device true or false​
    13·2 answers
  • Convert the following denary numbers into binary using 8-bit register:
    6·1 answer
  • Will Give Brainiest to the first correct answer!!!!
    10·2 answers
  • How to make classs constructer java.
    14·1 answer
  • Purchase computing resources as an outsourced service from suppliers who own and maintain all the necessary equipment and softwa
    5·1 answer
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!