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]
3 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]3 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
Which of the following is NOT necessary for organizing data to make it easier to sort?
Elenna [48]

Answer:

All the data must be the same font and font size is not necessary for data sorting.

Explanation:

The most easier and frequently used tool for data organizing and sorting is Microsoft's excel or google spreadsheet. Sorting deals with arrangement of  data values in a particular sequence or order according to defined rules. For example data can be sort in ascending or descending order as per values or names in list.

7 0
3 years ago
On a vehicle with a manual transmission, a frequent mistake is shifting
Vanyuwa [196]
On a vehicle with a manual transmission, a frequent mistake is shifting into a higher gear at too slow speed.
When shifting gears on the vehicle with a manual transmission, you should press the clutch all the way to the floor.
There are two types of transmissions of vehicles, manual and automatic. In manual transmission driver is responsible for shifting gears as the speed f vehicle changes while in automatic driver does minimal work. 
8 0
3 years ago
The term ____ is a technical term for the region of memory that holds data waiting to be transferred from one device to another.
shutvik [7]
<span>buffer is what your looking for    my friend made this  it should help  https://quizlet.com/20507517/ch-4-operating-systems-and-file-management-flash-cards/</span>

8 0
3 years ago
Windows workstations all have elements of server software built-in. What are these elements, and why is the Windows Professional
lions [1.4K]

Answer:

The answer is below

Explanation:

Elements of Server software that is built-in, in Windows workstations are:

1. Hard drives,

2. RAM (Random Access Memory)

3. Processors

4. Network adapters.

Windows Professional OS is not considered a server due to the following:

1. Windows Professional OS has a limit on the number of client connections it allowed.

2. Unlike Server, Professional OS uses less memory

2. In comparison to Server, Professional OS uses the CPU less efficiently

4. Professional OS is not built to process background tasks, unlike Server that is configured to perform background tasks.

6 0
3 years ago
List and briefly describe the major types of system in organization?​
Anni [7]

The major types of systems in the organization are:

  1. Operational Level system
  2. Management Level system
  3. Strategic Level system  

The classification of information systems based on organization levels is determined by the specialties and interests in some functional areas.

Operational-level systems assist operational managers by tracking the organization's basic operations and transactions, as well as the movement of materials in a factory. The primary function of systems at this level is to respond to routine inquiries and to record the movement of transactions via the organization. In general, information must be easily accessible, up to date, and accurate.

Management-level systems support middle managers' observing, regulating decision-making, and administrative operations. The primary question tackled by such systems is:

  • Are things running smoothly?

Management-level systems usually give regular reports rather than real-time operational data.

Strategic-level systems assist senior management in addressing strategic challenges and long-drawn patterns, both inside the organization and in the external world. Their primary focus is harmonizing external adjustments in the environment with current organizational capacity. 

Therefore, from the above explanation, we can conclude that we've fully understood the types of systems in the organization of information systems.

Learn more about information systems here:

brainly.com/question/13299592?referrer=searchResults

7 0
2 years ago
Read 2 more answers
Other questions:
  • Show what this program prints. Be exact and complete. Can you explain the behavior of each print statement? 1 2 3 4 5 6 7 public
    12·1 answer
  • There is a simple pattern for determining if a binary number is odd. What is it and why does this pattern occur
    6·2 answers
  • A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent. Which line is th
    13·1 answer
  • What will be the value of i after the C statements at the right have been executed
    6·1 answer
  • Carly is part of a community of developers. In her free time, she works on code to improve this open-source operating system. Th
    11·1 answer
  • How to write greater than or equal to in excel if function
    7·1 answer
  • What is a word processor in ms word​
    9·2 answers
  • Write a Java application that uses the Math class to determine the answers for each of the following: a. The square root of 37 b
    10·1 answer
  • What science category includes physics and biology?
    14·1 answer
  • ( BRAINLIEST) <br> Name 2 input devices and 2 output devices on a smart phone.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!