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
NARA [144]
4 years ago
14

The Account class contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and a

ccount number, and return a String representation. Modify the file as follows:1. Overload the constructor as follows:a. public Account (double initBal, String owner, long number) - initializes the balance, owner, and account number as specified.b. public Account (double initBal, String owner) - initializes the balance and owner as specified; randomly generates the account number.c. public Account (String owner) - initializes the owner as specified; sets the initial balance to 0 and randomly generates the account number.2. Overload the withdraw method with one that also takes a fee and deducts that fee from the account.
Computers and Technology
1 answer:
melamori03 [73]4 years ago
8 0

Answer:

I've updated the Account class as per the instructions. The instructions mention "the constructor for this class creates a random account number" although I didn't find where that was. As a result, I created a simple method to generates the account number (located at the bottom of the class). Be sure you understand the changes (highlighted in yellow) and feel free to ask follow-up questions:

Explanation:

//*******************************************************

// Account.java

//

// A bank account class with methods to deposit to, withdraw from,

// change the name on, and get a String representation

// of the account.

//*******************************************************

import java.util.Random;   // Used for Random # generator

public class Account

{

      private double balance;

  private String name;

     private long acctNum;

      //----------------------------------------------

 //Constructor -- initializes balance, owner, and account number

  //----------------------------------------------

 public Account(double initBal, String owner, long number)

{

        balance = initBal;

               name = owner;

            acctNum = number;

}

// !!!!!! New Constructor !!!!!!

public Account(double initBal, String owner)

     {

        balance = initBal;

               name = owner;

            acctNum = generateAccountNumber();

       }

  // !!!!!! New Constructor !!!!!!

 public Account(String owner)

     {

        balance = 0;

             name = owner;

            acctNum = generateAccountNumber();

       }

   //----------------------------------------------

 // Checks to see if balance is sufficient for withdrawal.

// If so, decrements balance by amount; if not, prints message.

  //----------------------------------------------

 public void withdraw(double amount)

      {

        if (balance >= amount)

                balance -= amount;

               else

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

}

 // !!!!!! New withdraw() method !!!!!!

   public void withdraw(double amount, double fee)

  {

        double amountWithFee = amount + fee;

               if (balance >= amountWithFee)

                 balance -= amountWithFee;

        else

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

}

   //----------------------------------------------

 // Adds deposit amount to balance.

       //----------------------------------------------

 public void deposit(double amount)

       {

        balance += amount;

       }

  //----------------------------------------------

 // Returns balance.

      //----------------------------------------------

 public double getBalance()

       {

        return balance;

  }

    //----------------------------------------------

 // Returns a string containing the name, account number, and balance.

    //----------------------------------------------

 public String toString()

 {

        return "Name:" + name +

          "\nAccount Number: " + acctNum +

         "\nBalance: " + balance;

 }

 // !!!! NEW PRIVATE HELPER METHOD TO GENERATE ACCOUNT NUMBERS !!!!!

//-------------------------------------------------------

// Returns a random account number between 10000 - 99999

 //--------------------------------------------------------

       private long generateAccountNumber()

     {

        Random r = new Random();        // Seed the random number genertor with the system time

         return 10000 + r.nextInt(89999);        // .nextInt(89999) will return a value between 0 and 89999)

      }

}

You might be interested in
Brenda also orders movies and television through the Internet via a(n) ____ provider, which allows users to download video for a
Novay_Z [31]

Brenda also orders movies and television through the Internet via a(n) VOD provider, which allows users to download video for a fee.

<h3>What is the meaning of the term VOD?</h3>

The term video-on-demand (VOD) is known to be a kind of technology made to send video content, such as movies and television programs, directly to specific customers for quick viewing.

Note that technology is constantly growing and one need to grow along with it. services that are good is often adopted by people.

Hence, Brenda also orders movies and television through the Internet via a(n) VOD provider, which allows users to download video for a fee.

Learn more about movies from

brainly.com/question/27936956

#SPJ1

5 0
2 years ago
What term is used to record successful and unsuccessful access attempts
MArishka [77]
I think it is called an audit trail. 
6 0
4 years ago
Explain in detail, how the Depth Wavelet Transform (DWT) algorithm works, specifically with respect to EEGs (a non-invasive brai
andreyandreev [35.5K]

Electroencephalography-(EEG-) based control is a noninvasive technique which employs brain signals to control electrical devices/circuits.

This should help you

3 0
2 years ago
I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
Oksana_A [137]

Answer:

Pseudocode:

import random

fetch user input on a lucky number

insert input into variable - "response"

new variable, random = randint

condition to check wheather random is our response

display results

Python Code:

import random

def main():

response = int(input("Guess my lucky number, its between 1 and 100: "))

lucky_number = random.randint(1,100)

if response == lucky_number:

print(f"Wow you're right, it is {lucky_number}")

else:

print("Sorry, Try Again")

main()

Reminder:

intended for python3 as i included the format f

also it could be done without the import, just manually insert a number

i'll leave the post mortum to you

Explanation:

3 0
3 years ago
Explain the steps users can take to maintain an operating system
Mars2501 [29]

First is it to always clean out all the junk that is left behind by the operating system and the browsers. You can easily do this using the Disk Cleanup utility included on the windows systems. You can clean up the registry. However, you should be very careful with the registry. Any wrong move might mess up everything


Search and destroy viruses and malware on your PC by installing an anti-virus security program and setting up an automated maintenance schedule.


Defragment main and partitioned drives to keep your computer running smoothly.


Uninstall software programs and personal files like pictures, movies and music that are no longer in use to free up more space. The more the space, the faster the PC will go. You can also run the msconfig command in the RUN command prompt to uncheck start up programs that you do not use

4 0
3 years ago
Other questions:
  • In two or more complete sentences, summarize the difference between renewable and nonrenewable resources? Justify your responses
    13·2 answers
  • Which dialog box opens after selecting a cell in the list of prepared data, clicking the insert tab on ribbon and the clicking t
    6·1 answer
  • What type of power flaw involves a fluctuation in voltage levels caused by other devices on the network or by EMI?
    13·1 answer
  • For this lab you will find the area of an irregularly shaped room with the shape as shown above.
    7·1 answer
  • What were the technological innovations that allowed for the rapid expansion of the railroads?
    6·1 answer
  • This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
    7·1 answer
  • How do the steps taken by leaders of Athens reflect a turn towrd democracy
    10·1 answer
  • How is an API different from a web application?
    10·1 answer
  • I really need this answer please
    5·1 answer
  • I'm pretty sure most of you know squid game, right? Well, are the actors really dying? or is it just CGI or effects? Because it'
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!