Can somebody help me a java code for this problem? Thanks Create an application
ID: 3535933 • Letter: C
Question
Can somebody help me a java code for this problem? Thanks Create an application that performs various actions related to a bank account BANK ACCOUNT Part A: Create file Account.java. File Account.java contains a class representing a bank account similar (Note that the constructor generates the account number randomly.) Save this file to your directory and use it in Part B. Class Account allows deposit, withdraw, and inquire. This class contains: Constructor: initialize account information (ex. A/C name and A/C number) and account balance. Withdraw method: deducts amount from current balance. Deposit method: adds amount to current balance. Inquiry method: returns current balance. ToString method: returns account information in a nice string. Example: Name: "Account Name" Balance: "Account Balance" Account Number: "Account Number." Number of Account method: returns the total number of accounts. Requirement: Use Random function to create account number. Random Function: Math.random(). Withdraw method -- Deducting amount from balance, if balance doesn't cover withdrawal, prints message "insufficient funds" and does not change the balance. Suppose the bank wants to keep track of how many accounts exist. Declare a private static integer variable numAccounts to hold this value. It will automatically be initialized to 0. Add code to the constructor to increment this variable every time an account is created. Add a static method numAccounts that returns the total number of accounts. (Think about why this method should be static -- its information is not related to any particular account.) Part B: Create file AccountTest.java to test Account.java follow on the following requirements: Create a new account from Account.java. The account name is " Mike" and initial balance is 500. Get Account information. Deposit an amount of 500 to Mike account and inquire new balance. Create a new account from Account.java. The account name is " Susan" and initial balance is 100. Withdraw an amount of 50 from Susan account and inquire new balance. Withdraw another amount of 70 from Susan account. (You should get message insufficient funds at this point.) Returns the total number of accounts.Explanation / Answer
brittany p, I've written and completed this. I'll give you some hints. If you can't get it let me know and I'll explain as best as I can. But the best way to learn is to try it yourself then ask for help, trust me I went through the same thing not too long ago. 1. After you create class Account, define your variables, accountName, accountNumber, balance, and numAccounts. Remember to initialize numAccounts to 0. 2. Define your constructor. You'll only need 2 parameters since account # is a random number: accountName and balance. Set your variables you defined in step 1 to these parameter values. And set accountNumber to Math.random(); 3. Write your methods. public void withdraw(double amount), public void deposit(double amount), public double inquiry(), public String toString(), and finally public static int numAccounts(). Remember, when writing withdraw you need to look at how much is in the account and how much is requested for withdraw. hint hint use an if else statement. Deposit is the same thing as withdraw, only backwards and don't need to look into the balance to do it. toString is pretty self explanatory. Finally, numAccounts simply returns the numAccounts variable. 4. Create an object "mike" with the account class and put ("Mike",500) in the parameters. Follow instructions from there.