Re: CS506 Assignment 1 Solution and Discussion
Please read the following instructions carefully before solving & submitting assignment:
Uploading Instructions:
• You are not allowed to use any IDE tool like NetBeans for this assignment.
• Use Notepad or Notepad++ for coding and JDK package for Java source code compilation and running.
• Place all the source code (.java & .class files) in a Zip/RAR file, save with your own Student ID (e.g. bc000000000.zip) and Upload it on VULMS within due date.
• Your assignment should be in .zip /.rar format. Other file formats will not be accepted.
• No assignment will be accepted through email.
Rules for Marking:
It should be clear that your assignment will not get any credit if:
o The assignment is submitted after due date.
o The submitted assignment does not open or file is corrupted.
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet; strict disciplinary action will be taken in this case.
o The assignment is not submitted in .zip /.rar format.
Note: Do not put any query on MDB regarding this assignment, if you have any query then email at [email protected]
Lectures Covered: This assignment covers Lectures # 1 to 9
GOOD LUCK
Problem Statement:
You are required to develop a Java program named MyATM, which should simulate behavior of a typical ATM (Automated Teller Machine). In which a user, after entering card details, can deposit amount, withdraw cash and view current balance. The program should be based on a user friendly interface; need to use Java basic GUI component (i.e. JOptionPane) for this purpose. Further, all information must be saved in a backend database using simple text file.
Detailed Description:
At start, your program should ask the user to provide card number (e.g. vu-bsxxxxxxx) and pin code (e.g. 1234) as input. After taking input from user the program should fetch user data corresponding to the input from database (i.e. text file) and store in a global variable (e.g. debitCard). Taking input from user is shown in figure no 1.
Fig. 1: Taking input from User
If input values are correct (i.e. provided values are same as given in text file) then following ATM services should be displayed via GUI;
- Deposit Amount
- Withdraw Cash
- Check Balance
- Exit the Program
However, in case, if input values are not correct (i.e. found no user against provided card number and pin code) then appropriate message should be shown, like; “Invalid Card No or wrong Pin Code”. Fig. 2: ATM Services GUI
- Deposit Amount:
Each time, user selects this option, s/he will be prompted to enter money for deposit that must be in multiple of Rs. 500/- (hint is given below) and up to a maximum of Rs. 25000/- per transaction. If inputs are correct then the amount must be added in current balance and as well as in database. However, in case of wrong input, appropriate message should be displayed.

Fig. 3: Deposit Amount GUIs
- Withdraw Cash:
User can withdraw any cash but in multiple of Rs. 500/- (hint is given below) and up to a maximum of Rs. 25000/- per transaction by using this option. However, if balance is zero or withdraw amount is greater than the balance, then appropriate message should be displayed. Otherwise, amount must be deducted from current balance and database should be maintained.

Fig. 4: Cash Withdraw GUIs
- Check Balance:
The program should fascinate the user by displaying the current balance via GUI.

Fig. 5: Check Balance GUI
- Exit the Program:

Before exiting, the program should display the developer information (i.e. Student Id and name) via GUI.
Fig. 6: Developer Info GUI
Required Stuff:
For this purpose, you have to create a text file and three separate Java classes, details are as follows;
Text File:
A simple text file, which should contain single line “vu-bsxxxxxxx,1234,0” in it and must be saved as bsxxxxxxx.txt.
Here, “bsxxxxxxx” at both (i.e. file name and single line text) must be same as your own student id.
And “vu-bsxxxxxxx” is card no, “1234” is pin code and “0” is initial balance.

Fig. 7: Sample Data in Database (.txt file)
DebitCard.java:
Data Members:
• cardNo: String
• pin: int
• balance: long
Constructors:
• default, parameterized & copy constructor
Standard Setters:
• setCardNo(…), setPin(…) & setBalance(…)
Standard Getters:
• getCardNo(), getPin()& getBalance()
DbHelper.java:
Data Members:
• FILE_NAME: String // static and final variable
Member Functions:
• loadData() & saveData(…)
Main Class:
Data Members:
• debitCard: DebitCard
• dbHelper: DbHelper
Constructor:
• default
Member Functions:
• main(…), initLoginGUI(), initServicesGUI(), depositAmoount(), cashWithdraw(), checkBalance() & showDeveloperInfo()
Hint:
if (amount % 500 == 0) {
// it is a multiple of 500.
}
Video Tutorials:
To download & install JDK and create a HellowWorld program in Java, please watch;
To download JDK setup file for Windows x64 from VU-LMS,
please visit;
Important Things to Implement:
You have to provide Java classes in separate .java files as guided above. Merging of two or more will result in deduction of marks.
Each Java class must have proper Data Members and Member Functions along with Constructors, Standard Setters and Getters etc. as discussed above.
For GUI, you have to use JOptionPane.showInputDialog and JOptionPane.showMessageDialog for taking input from user and showing output to user respectively.
Need to make sure that exceptions are managed properly throughout the program; especially NullPointerException and NumberFormatException while taking input from user.
All images and sample data, given in this document, are just for reference purpose only; you have to provide your own implementations. It is not required to be exactly the same.
Good Luck