[JAVA]
< Instruction>
You are given two classes, BankAccount and ManageAccounts
ManageAccounts is called a Driver class that uses BankAccount.
associate a member to BankAcount that shows the Date and Time
that Accounts is created. You may use a class Date. To find API on
class Date, search for Date.java. Make sure to include date information
to the method toString().
you must follow the instruction and Upload two java files.
BankAccount.java and ManageAccounts.java.
--------------------------------------------------------------------------
A Bank Account Class
// *******************************************************
// Account.java
//
// A bank account class with methods to deposit to, withdraw from,
// change the name on, charge a fee to, and print a summary of the account.
// *******************************************************
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;
}
// --------------------------------------------
// 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");
}
// --------------------------------------------
// 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()
{
}
// --------------------------------------------
// Deducts $10 service fee //
// --------------------------------------------
public void chargeFee()
{
}
// --------------------------------------------
// Changes the name on the account
// --------------------------------------------
public void changeName(String newName)
{
}
}
// ************************************************************
// ManageAccounts.java
//
// Use Account class to create and manage Sally and Joe's
// bank accounts
// ************************************************************
public class ManageAccounts
{
public static void main(String[] args)
{
Account acct1, acct2;
//create account1 for Sally with $1000 acct1 = new Account(1000, "Sally", 1111);
//create account2 for Joe with $500
//deposit $100 to Joe's account
//print Joe's new balance (use getBalance())
//withdraw $50 from Sally's account
//print Sally's new balance (use getBalance())
//charge fees to both accounts
//change the name on Joe's account to Joseph
//print summary for both accounts
}
}
Account.java :
// *******************************************************
// Account.java
//
// A bank account class with methods to deposit to, withdraw
from,
// change the name on, charge a fee to, and print a summary of the
account.
// *******************************************************
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;
}
// --------------------------------------------
// 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");
}
// --------------------------------------------
// 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 "Account Holder Name
:"+name+"\nAccount Number: "+acctNum+"\nBalance:"+balance;
}
// --------------------------------------------
// Deducts $10 service fee //
// --------------------------------------------
public double chargeFee()
{
balance=balance-10;//deduct 10 from
the balance
return balance;//return
balance
}
// --------------------------------------------
// Changes the name on the account
// --------------------------------------------
public void changeName(String newName)
{
name=newName;//change name
}
}
************************************
ManageAccounts.java :
//
************************************************************
// ManageAccounts.java
//
// Use Account class to create and manage Sally and Joe's
// bank accounts
//
************************************************************
public class ManageAccounts // Java class
{
//main() method-which is entry point
public static void main(String[] args) {
//creating object of Account class
Account acct1, acct2;
//create account1 for Sally with $1000
acct1 = new Account(1000, "Sally",
1111);
//create account2 for Joe with $500
acct2 = new Account(500, "Joe",
2222);
//deposit $100 to Joe's account
acct2.deposit(100);
//print Joe's new balance (use getBalance())
System.out.println("Joe's new
balance :"+acct2.getBalance());
//withdraw $50 from Sally's account
acct1.withdraw(50);
//print Sally's new balance (use getBalance())
System.out.println("Sally's new
balance : "+acct1.getBalance());
//charge fees to both accounts
acct1.chargeFee();
acct2.chargeFee();
//change the name on Joe's account to Joseph
acct2.changeName("Joseph");
//print summary for both accounts
System.out.println(acct1.toString());
System.out.println(acct2.toString());
}
}
===============================
Output :Compile and Run ManageAccounts.java to get the screen as shown below
[JAVA] < Instruction> You are given two classes, BankAccount and ManageAccounts ManageAccounts is called a Driver...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
java code ============= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...
Implement a class Portfolio. This class has two objects, checking and savings, of the type BankAccount. Implement four methods: • public void deposit(double amount, String account) • public void withdraw(double amount, String account) • public void transfer(double amount, String account) • public double getBalance(String account) Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer, it indicates the account from which the money is taken; the money is...
java code ========= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...
TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...
C++ Please create the class named BankAccount with the following properties below: // The BankAccount class sets up a clients account (name & ID), keeps track of a user's available balance. // It also keeps track of how many transactions (deposits and/or withdrawals) are made. public class BankAccount { Private String name private String id; private double balance; private int numTransactions; // Please define method definitions for Accessors and Mutator functions below Private member variables string getName(); // No set...
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package checkingaccounttest; // Chapter 9 Part II Solution public class CheckingAccountTest { public static void main(String[] args) { CheckingAccount c1 = new CheckingAccount(879101,3000); c1.deposit(350); c1.deposit(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.withdraw(350); c1.withdraw(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.deposit(1000); System.out.println(c1); System.out.println("After calling computeMonthlyFee()"); c1.computeMonthlyFee(); System.out.println(c1); } } class BankAccount { private int...
Requirements: Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below. BankAccount: an abstract class. SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...
According to the following information, define Account, CheckingAccount, and TestPart1 classes. 1. Account and CheckingAccount classes Account - number: int - openDate: String - name: String - balance: double + Account(int, String, String, double) + deposit(double): void + withdraw (double): boolean + transferTo(Account, double): int + toString(): String CheckingAccount + CheckingAccount(int, String, String, double) + transferTo(Account, double): int Given the above UML diagam, define Account and CheckingAccount classes as follow: Account (8 points) • public Account(int nu, String op, String...