0% found this document useful (0 votes)
49 views

(The Account Class) Design A Class Named Account That Contains

The document describes an assignment to design a class called Account to model bank accounts. The Account class contains fields like id, balance, interest rate and date created, along with accessor and mutator methods. It also includes methods to calculate monthly interest and allow deposits and withdrawals. Students are tasked with drawing a UML diagram and implementing the class. The second part of the assignment involves creating an ATM simulation that uses an array of Account objects, prompts the user for an ID and displays a menu to view balances, withdraw/deposit funds, and exit.

Uploaded by

imamtambo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

(The Account Class) Design A Class Named Account That Contains

The document describes an assignment to design a class called Account to model bank accounts. The Account class contains fields like id, balance, interest rate and date created, along with accessor and mutator methods. It also includes methods to calculate monthly interest and allow deposits and withdrawals. Students are tasked with drawing a UML diagram and implementing the class. The second part of the assignment involves creating an ATM simulation that uses an array of Account objects, prompts the user for an ID and displays a menu to view balances, withdraw/deposit funds, and exit.

Uploaded by

imamtambo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

The Institute of Finance Management

Faculty of Computing, Information Systems and Mathematics


Computer Science Department
Bachelor of Computer Science & Bachelor of Science in Information
Technology
Object Oriented Programming
Lab 6

1. (The Account class) Design a class named Account that contains:


 A private int data field named id for the account (default 0).
 A private double data field named balance for the account (default 0).
 A private double data field named annualInterestRate that stores the current
interest rate (default 0). Assume all accounts have the same interest rate.
 A private Date data field named dateCreated that stores the date when the
account was created.
 A no-arg constructor that creates a default account.
 A constructor that creates an account with the specified id and initial balance.
 The accessor and mutator methods for id,balance, and annualInterestRate.
 The accessor method for dateCreated.
 A method named getMonthlyInterestRate() that returns the monthly interest
rate.
 A method named getMonthlyInterest() that returns the monthly interest.
 A method named withdraw that withdraws a specified amount from the
account.

A method named deposit that deposits a specified amount to the account.


Draw the UML diagram for the class and then implement the class. (Hint: The
method getMonthlyInterest() is to return monthly interest, not the interest rate.
Monthly interest is balance*monthlyInterestRate. monthlyInterestRate is
annualInterestRate / 12. Note that annualInterestRate is a percentage, e.g., like 4.5%.
You need to divide it by 100.)

2. (Game: ATM machine) Use the Account class created above. Create ten accounts in
an array with id 0, 1, . . . , 9, and initial balance TSHS 100. The system prompts the
user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id.
Once an id is accepted, the main menu is displayed as shown in the Figure below.
You can enter a choice 1 for viewing the current balance, 2 for withdrawing money, 3
for depositing money, and 4 for exiting the main menu. Once you exit, the system
will prompt for an id again. Thus, once the system starts, it will not stop.

1
2

You might also like