Question
Hello guys I have copied and pasted a java code undearneath and have attached the requirement for it. Some help would be greatly appreciated. public
Hello guys I have copied and pasted a java code undearneath and have attached the requirement for it. Some help would be greatly appreciated.
public class BankAccount {
//private data members, means accessible to only this class
private int accountNumber; // Holds account number of user
private String ownerName; // Holds name of user
private double balance; // Holds total balance in account
private String type; // Personal, business, Charitable
// Default constructor
// This constructor initializes data members with some default values
public BankAccount() {
accountNumber=0;
ownerName="";
balance=0.0;
type="Personal";
}
// Parameterized constructor
// This constructor initializes data members with values passed in arguments
public BankAccount(int number, String name, double initialDeposit, String type) {
accountNumber = number; // Sets account number with number
ownerName = name; // Sets owner name with name
balance = initialDeposit;// Set balance with initial deposit
// Here, this is used because the variable name of data member and parameter is same
// "this" here refers to the current object for which the constructor is called
this.type = type; // Sets type with passed value type
}
// Getter method which returns account number
public int getAccountNumber() {
return accountNumber;
}
// Setter method which can be used to set a new account number
public void setAccountNumber(int number) {
accountNumber = number;
}
// Getter method which returns owner name
public String getOwnerName() {
return ownerName;
}
// Setter method which can be used to set a new owner name
public void setOwnerName(String name) {
ownerName = name;
}
// Getter method which returns balance in account
public double getBalance() {
return balance;
}
// Setter method which can be used to set new balance
public void setBalance(double newAmount) {
balance = newAmount;
}
// Getter method which returns tyoe of account
public String getType() {
return type;
}
// This method add passed amount to balance and updates balance
public void deposit(double amount) {
balance+=amount;
}
// This method subtract passed amount from balance and updates balance
public void withdrawal (double amount) {
balance -=amount;
}
// This method returns a string with following details -
// type : accountNumber ownerName balance
// Example - Personal: 12345 Max 25000
public String ToString() {
return type + ": " + accountNumber + " " + ownerName + " " + balance;
}
}
In a different Java class, called ClientUpdate.java, create a bank's client processing program with the following specifications: The single client's file contains information on all that person's accounts (personal, business and charitable), including deposits, withdrawals, interest earned and charges. These are all stored in a text file, the name of the file should be input from the keyboard. The first line of the file contains an integer, called number, indicating the number of accounts and the client's name. The next number lines of the file contain, for each account, a String token indicating the type of the account and a unique integer representing the account number and a real number indicating the starting balance. o o An array of BankAccounts can be created to hold the client file information. Use a constructor from the BankAccount class to instantiate each of the accounts. Following that, there are an unknown number of lines, each contains the integer identification number for the account, a String (one of "deposit", "withdrawal", "interest", "charge") indicating the type of transaction, and a real number indicating the amount of the transaction. o The amount of a deposit must be added to the BankAccount's balance; " The amount of a withdrawl must be subtracted from the balance; . The amount of interest requires adding 'amount, % interest to the account; . The amount of a (service) charge must be subtracted from the account. Use member methods of the BankAccount class to alter the attributes of the appropriate BankAccount object. Once the entire file has been processed output all attributes of each account to the screen: o Use the instance method called toString () to make a single String containing all attributes of a BankAccount object that is being printedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started