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
Everfi module 7 answers
Nat2105 [25]
What is the question?
7 0
2 years ago
The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
marta [7]

Answer:.......

void clear(int *array, int length){

 

  if (length == 0)return;  

 

  array[0] = 0;  

 

  clear(array + 1, length-1);

}

Explanation:

The void function accepts an integer array.

7 0
3 years ago
Which of the following statements is not correct ​
just olya [345]
Wich statements ? I don’t see anything
4 0
2 years ago
Read 2 more answers
Phân tích vai trò của các yếu tố trong biên tập Audio và Video
Paul [167]

Answer:

Answer to the following question is as follows;

Explanation:

A visual language may go a long way without even text or narrative. Introductory angles, action shots, and tracker shots may all be utilised to build a narrative, but you must be mindful of the storey being conveyed at all times. When it comes to video editing, it's often best to be as cautious as possible.

6 0
3 years ago
Let's now use our new calculator functions to do some calculations!
Sophie [7]

Answer:

Ans1.

double calc_a;

calc_a=Math.pow(3.0,2.0)+Math.sqrt(9);

Ans2.

double calc_b;

calc_b=((12.0/3.0)-(2.0*4.0));

Ans 3.

double calc_c;

calc_c=(Math.sqrt(16.0)*(7.0+9.0));

Ans 4.

double calc_d;

calc_d=Math.pow(7.0,2.0)/Math.sqrt(49.0);

Explanation:

The expressions are done with Java in answer above.

6 0
3 years ago
Other questions:
  • Which of the following criteria would not make a person eligible to receive medicare benefits?Which of the following criteria wo
    12·2 answers
  • Explain the difference between an i/o‐bound process and a cpu‐bound process.
    12·1 answer
  • 1. What is the main factor that affects Earth’s average temperature?
    12·1 answer
  • If you wanted to include a chart in the new slide you are getting ready to create, you would most likely
    9·1 answer
  • What happens if the user sysadmin invokes the mail command interface and there are no unread mail messages?
    13·1 answer
  • A large number of genetic codes are stored as binary values in a list. Which one of the following conditions must be true in ord
    5·2 answers
  • A _______ attack uses software to try thousands of common words sequentially in an attempt to gain unauthorized access to a user
    9·2 answers
  • Guidewords for the word “serpent” may be
    8·2 answers
  • Common names for computer-based information systems are transaction processing, management information, ________, and executive
    5·1 answer
  • Discussion Topic
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!