Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Important Note: All submitted assignments must begin with the descriptive commen

ID: 3593211 • Letter: I

Question

Important Note: All submitted assignments must begin with the descriptive comment block. To
avoid losing trivial points, make sure this comment header is included in every assignment you submit.
/*-------------------------------------------------------------------------
// AUTHOR: your name
// FILENAME: title of the source file
// SPECIFICATION: description of the program
// YOUR Lab Letter and Name of the TA for your Closed lab
// FOR: CSE 110- homework #- days and time of your class
// TIME SPENT: how long it took you to complete the assignment
//----------------------------------------------------------------------*/
Overview
For this assignment, you will be designing a class that represent a Bank Account object and
banking activities. Each Bank Account object has only 3 instance variables: an id, checking
balance and Saving balance. This Bank account class represents a regular account.
Project Specification
Your Class BankAccount must include the following constructors and methods.
Methods & Constructors Description
BankAccount( ) Default constructor, sets the id to "???", and balances to 0.
BankAccount(String
initID, double
initChecking, initSaving)
Constructs a BankAccount object given the id as a String, and
balances for checking and saving as doubles.
private String getID( ) Access this account's unique identifier.
public double
getChecking( ) Access this account's current balance in checking account
public double getSaving(
) Access this account's current balance in saving account
public getBalance() Returns total balance of checking and saving
public void setID(String
name) Sets the id
public void
deposit(depositAmount)
Credit this account’s checking by depositAmount , if deposit
amount is negative or zero the balance will not change.
public boolean
withdraw(withdrawAmount )
Debit this account’s checking balance by withdrawAmount if it
is positive and not greater than this account's current balance. It
returns true if 0 <withdrawAmount <=the balance
public void addInterest(
)
Adds 2.5 percent interest to the account if the account balance is
less than or equal to $1000.00, 3.5 percent if the account balance
is between 1000 and 5000 inclusive, and 4.5 percent if the
minimum balance is 5000.
public boolean
equals(String is)
checks for proper id and returns true if this BankAccount has the
same ID as the user input
public String toString( )
Returns a String with information on each BankAccount using
the following format: (make sure to print the balances with
currency Format)
ID: 23456
Checking Balance: $40,000.00
Saving Balance: $41,800.00
Save the BankAccount class in a file called BankAccount.java and use the following program
stored in Assignment5.java, which has the main method to create a new BankAccount object.
Important Notes: Your class should have exactly the method headers described above or otherwise your
class will not work with the test driver program (Assignment5.java) that is provided. You should not
change the test driver program if the test driver is provided but instead make changes to BankAccount
class to make it work.
Here are the options in Assignment 5:
Option a: deposit the amount entered to checking account
Option b: withdraw the amount entered from checking account
Option c: Display the balance
Option d: ask for customer id and prompt if it has entered correctly
Option ?: print the menu again
Option q: add the interest and quit the program
Helpful hints for doing this assignment:
• work on it in steps – write one method, test it with a test driver and make sure it works
before going on to the next method
• always make sure your code compiles before you add another method
• your methods should be able to be called in any order
Here is a sample output:
Welcome to CS110 BANK
What is your bank id? 45678
Initial deposit into Checking: 900
Initial deposit into Saving: 3000
Command Options
-----------------------------------
a: deposit
b: withdraw
c: display the balance
d: Check the account
?: display the menu again
q: quit this program
Please enter a command or type ?
a
Amount to deposit:
350
You deposited $350.00 to Checking.
Please enter a command or type ?
a
Amount to deposit:
400
You deposited $400.00 to Checking.
Please enter a command or type ?
b
Amount to withdraw: 300
You withdrew $300.00
Please enter a command or type ?
b
Amount to withdraw: 3000
Invalid choice (not sufficient fund)
Please enter a command or type ?
c
ID: 45678
Checking Balance: $1,350.00
Saving Balance: $3,000.00
Please enter a command or type ?
d
What is your bank id? 23456
Wrong ID!
Please enter a command or type ?
d
What is your bank id? 45678
Here is the balance: ID: 45678
Checking Balance: $1,350.00
Saving Balance: $3,000.00
Please enter a command or type ?
q
ID: 45678
Checking Balance: $1,397.25
Saving Balance: $3,105.00
Press any key to continue . .

Explanation / Answer

class Programming {
//constructor method
Programming() {
    System.out.println("Constructor method called.");
}

public static void main(String[] args) {
    Programming object = new Programming(); //creating object
}
}
class Language {
String name;

Language() {
    System.out.println("Constructor method called.");
}

Language(String t) {
    name = t;
}

public static void main(String[] args) {
    Language cpp = new Language();
    Language java = new Language("Java");

    cpp.setName("C++");

    java.getName();
    cpp.getName();
}

void setName(String t) {
    name = t;
}

void getName() {
    System.out.println("Language name: " + name);
}
}
class GrandParent {
int a;

GrandParent(int a) {
    this.a = a;
}
}

class Parent extends GrandParent {
int b;

Parent(int a, int b) {
    super(a);
    this.b = b;
}

void show() {
    System.out.println("GrandParent's a = " + a);
    System.out.println("Parent's b      = " + b);
}
}

class Child {
public static void main(String[] args) {
    Parent object = new Parent(8, 9);
    object.show();
}
}