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
Type the correct answer in the box. Spell all words correctly.
Kamila [148]

Answer:emphasis

Explanation:

7 0
3 years ago
Becca is working on a program that will store data. The program will need quick access to data and data persistence is not impor
borishaifa [10]

Based on the information given the data should be stored in flash memory.

<h3>What is flash memory:</h3>

Flash memory is a memory storage space that is used to store data or information on a computer.

Flash memory is vital as it help to retain information or data that are stored on a computer after power is removed which inturn means that store data can be retrieve when needed.

Example of flash memory are:

  • CompactFlash  
  • Memory Stick
  • BIOS chip etc

Inconclusion the data should be stored in flash memory.

Learn more about flash memory here:brainly.com/question/6835146

7 0
2 years ago
Help me guys pleassssssssse​
Readme [11.4K]

Answer:

is there a word bank??

Explanation:

8 0
3 years ago
Which of the following is the fastest growing input technique​
Natali [406]
We need more information for this one, please.
8 0
3 years ago
What do you call an optical instrument used for viewing small objects
devlian [24]
An optical instrument used for viewing small objects is a microscope
8 0
3 years ago
Other questions:
  • It is better to know the main components of all computer programming languages
    9·1 answer
  • Why has unicode become the standard way of converting binary to text
    7·1 answer
  • Why does this say I'm in middle school?
    11·1 answer
  • What is the use of word art?
    10·1 answer
  • _______ refers to the poitically, religiously, or ideologically motivated use of computers (or related technology) by an individ
    15·1 answer
  • You install a teanviewer on your work station at home so that you can access it when on the road. How can you be assured that un
    12·1 answer
  • How can i become an expert in computer and technology?
    15·2 answers
  • The _____ dialog box lets you specify which files are to be merged.
    14·1 answer
  • Kiera is building a new computer and wants to make sure she has an adequate power supply for all the new equipment she is purcha
    15·2 answers
  • Is the trust necessary to use an emerging technology platform? why?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!