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

week1-CodingAssessment

The document outlines the creation of a Java class structure for managing bank accounts, including an Account class with attributes like account number, customer name, account type, and balance. It specifies methods in the AccountService class for validating accounts, depositing, withdrawing funds, and checking balances, along with exception handling for various scenarios such as invalid amounts and insufficient funds. Additionally, it includes instructions for packaging the Java files and submitting them in a zip file named 'week1solution.zip'.

Uploaded by

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

week1-CodingAssessment

The document outlines the creation of a Java class structure for managing bank accounts, including an Account class with attributes like account number, customer name, account type, and balance. It specifies methods in the AccountService class for validating accounts, depositing, withdrawing funds, and checking balances, along with exception handling for various scenarios such as invalid amounts and insufficient funds. Additionally, it includes instructions for packaging the Java files and submitting them in a zip file named 'week1solution.zip'.

Uploaded by

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

1.

Create a class Account having the members as given below:


accno int
custname String
acctype String (indicates ‘Savings’ or ‘Current’) { use ENUM)
balance float

Include the following methods in the AccountService class:


boolean isValidAccount(Account account)
void deposit(float amt);
void withdraw(float amt);
float getBalance();

Use ArrayList with 5 account objects. List<Account> , in isValidAccount ()


method check whether given account number is existing or not if then
method should throw AccountNotFoundException

deposit(float amt) method allows you to credit an amount into the current
balance. If amount is negative, throw an exception
InvalidAmountException to block the operation from being performed.

withdraw(float amt) method allows you to debit an amount from the


current balance.
Minimum amount to withdraw is 500, if amt is < 500 throw an exception
InvalidAmountException
Please ensure a minimum balance of Rs.1000/- in the account for savings
account and Rs.5000/- for current account, else throw an exception
InsufficientFundsException and block the withdrawal operation.

Add constructor in Account to which you will pass, accno, custname, acctype
and initial balance and check whether the balance is less than 1000 in case
of savings account and less than 5000 in case of a current account. If so,
then raise a LowBalanceException.
In either case if the balance is negative then raise the
InvalidAmountException exception accordingly.

Classes to be created.

package com.ig.model
Class Account {
Integer accNumber;
String custName;
String type;// String (indicates ‘Savings’ or ‘Current’) { use ENUM)
Float balance;
}

Package com.ig.service

Class AccountService {
List<Account> accountList=new ArrayList<>();
Boolean isValidAccount(int acNumber)
void deposit(float amt);
void withdraw(float amt);
float getBalance();
}

package com.ig.ui

Class AccountTest{
Public static void main(String args[]) {
== call methods
}
}
Package com.ig.exception;
class InsufficientFundsException {
}

Class InvalidAmountException {
}

Class LowBalanceException {
}

Node: submit Zipfile with all java files and screenshot of execution. Name of
file- week1solution.zip

You might also like