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
For a typically large organization how many dns servers should you install
DiKsa [7]
<span>A large organization minimum at-least 2 DNS servers are needed. DNS servers are each internet domain in need. and Multiple server farms distribute the DNS Server. One of the DNS Server is must in separate location. install DNS server on all domain controller. DNS server on every domain controller is must.</span>
4 0
3 years ago
What is the easiest way to be sure you have selected all of the content related to a specific tag?
pychu [463]
Add a <div> around it.
example:
<div id = "content">
<p> content</p>
</div>
4 0
3 years ago
Organizational structures with one or more layers of authority between top-level management and employees are known as vertical
r-ruslan [8.4K]

The organizational structure described here, which is known as vertical organizational structure, is also commonly identified as tall organizations.

They usually have hierarchical structures, with the CEO being at the very top of the layer. Tall organization have multiple levels, compared to its counterpart, the flat organization or horizontal, which would only have one level.  

8 0
3 years ago
Read 2 more answers
A set of programs that enable the hardware to process data is _____.
Mnenie [13.5K]
The most appropriate answer is C !! software os used for using hardware !!
4 0
3 years ago
A teacher wants a program to give extra points to students who fail a test. Write a Python program to do the following: (a) Ask
Lorico [155]

Answer:

Hi there! Please find the answer below.

Explanation:

The program below demonstrates how each of the requirements can be coded in a simple Python script. To copy the array, we can use the copy() method of the array. To calculate the diff, we can use a few different techniques, so I have implemented it using a loop over the arrays and just storing and displaying the difference in the 2 arrays.

new_string.py

def add_test_score(score):

 test_score.append(score);

contact_hash = {}

test_score = []

print("Enter 5 test scores: ");

for x in range(0, 5):

   input_string = input("Enter test score " + str(x + 1) + ": ")

   add_test_score(int(input_string));

print(test_score);

test_score_copy = test_score.copy();

for e in test_score_copy:

   if e < 60:

       test_score_copy[test_score_copy.index(e)] += 10;

diff = [];

for e in test_score:

   print(test_score[test_score.index(e)]);

   print(test_score_copy[test_score.index(e)]);

   if not test_score[test_score.index(e)] == test_score_copy[test_score.index(e)]:

       diff.append(e);

print(diff);

8 0
3 years ago
Other questions:
  • In a five-choice multiple-choice test, which letter is most often the correct answer?
    7·2 answers
  • Why is it difficult to enforce laws against intellectual theft?
    10·1 answer
  • In the windows firewall, any rules preceded by a __________ checkmark have not been enabled. black gray green red
    13·1 answer
  • How to make flashcards on microsoft word 2010?
    7·1 answer
  • Which f the following is not a characteristic of igneous rock
    8·1 answer
  • How does voting help in a social news site?
    10·1 answer
  • How do you get banned? By getting reported? Or do admins watch whats posted?
    9·1 answer
  • 2ND LAST QUESTION
    13·1 answer
  • Every finger has a key it should be resting on when you are not typing<br> 1. False<br> 2. True
    12·2 answers
  • You are setting up a home network for your friend. She has students visiting her home regularly for lessons and wants to provide
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!