Java Programming: Bank Deposit and Interest Calculation

Verified

Added on  2022/08/26

|9
|798
|10
Homework Assignment
AI Summary
This Java assignment involves developing a program for a local bank to calculate interest on term deposits. The program takes client details (name, deposit amount, and term) as input, validates the data using try-catch blocks, and determines the interest rate based on the deposit amount. It then calculates the interest earned and the final balance, displaying the results in a formatted certificate. The solution includes the implementation of methods like `rateChecker()` and `calculateInterest()`, along with tests and data validation using various inputs. The assignment also includes a second task involving group entry calculations, taking inputs for the number of children, adults, and seniors, and calculating charges accordingly. The program utilizes a `while` loop for group entry and a `calculateCharge()` method to determine the charges based on the number of unaccompanied children. The solution provides outputs for different scenarios, including valid and invalid data inputs, and demonstrates the program's functionality through various test cases.
Document Page
Running head: PROGRAMMING IN JAVA
PROGRAMMING IN JAVA
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1PROGRAMMING IN JAVA
Table of Contents
Task 1:........................................................................................................................................2
Tests and Data Validation:.....................................................................................................3
Outputs:..................................................................................................................................4
Task 2.........................................................................................................................................6
Document Page
2PROGRAMMING IN JAVA
Task 1:
Task one mainly consists of taking inputs like taking deposit amount and duration of
the deposit from the user, validate the correctness of the input, finding out the proper rate as
per the entered deposit amount, calculate interest amount and finally display a bank
certificate containing name of the bank, Client’s name, Deposit amount, Duration, Interest
earned and Final balance.
Initially, in the main method, all the details like client name, deposit amount and
duration of the deposit are taken as an input using the object of Scanner mentioned as sc. The
deposit amount and duration were checked using try catch block to handle any type of
exception and print a proper message on handling the same (Exception) (Asaduzzaman et al.,
2016). Upon taking all the data from the user, rateChecker() method is called to determine the
correct rate of interest that the client can avail against his/her deposit amount (Sharan, 2018).
After the rate is determined, earned interest is calculated next by calling the
calculateInterest() method. In the method, total interest amount is calculated using deposit,
rate and tame then returns the interest to the main method. Finally, the main method calls the
display the certificate in a formatted layout.
Document Page
3PROGRAMMING IN JAVA
Tests and Data Validation:
Table: Displaying three valid data tests and two validation test with abnormal input
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4PROGRAMMING IN JAVA
Outputs:
Fig 1: Output, upon entering same data to that of the problem statement
Fig 2: Output, upon entering different data to that of the problem statement
Document Page
5PROGRAMMING IN JAVA
Fig 3: Output, upon entering different data to that of the problem statement
Fig 4: Output, upon entering invalid data in deposit amount section
Fig 5: Output, upon entering invalid data in deposit duration section
Document Page
6PROGRAMMING IN JAVA
Task 2
In task two, a confirmation is taken from the user about whether s/he wants to take
enter data of groups entering or not with yes=1 and no=2. From the problem scenario, it
seemed like the entry of the group should always be enabled on pressing 1 and on 0 the final
takings will be displayed. Hence for this reason a while loop is taken to perform all the tasks
related to group entry until 0 is pressed in the proper section (Horstmann, 2016). Inside the
while loop, details like number of children, adults and seniors entering the zoo is taken as an
input and they were passed through calculateCharge() method to calculate the charge for each
group and assigned the returned value to charge variable for further calculation (Cifuentes,
Gross & Keynes, 2015).
Inside the calculateCharge() method, initially it is checked whether the total of senior
and adults is greater or equal to children, on finding the condition true, the result is returned
to the main method; if the condition is false, charge is calculated by finding total
unaccompanied children and returned to main. Finally calculating the takings in main method
while loop and printing outside the while loop.
Fig 6: Output, upon entering same data to that of the problem statement
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7PROGRAMMING IN JAVA
Fig 7: Output, upon entering different data to that of the problem statement
Document Page
8PROGRAMMING IN JAVA
References
Asaduzzaman, M., Ahasanuzzaman, M., Roy, C. K., & Schneider, K. A. (2016, May). How
developers use exception handling in Java?. In 2016 IEEE/ACM 13th Working
Conference on Mining Software Repositories (MSR) (pp. 516-519). IEEE.
Cifuentes, C., Gross, A., & Keynes, N. (2015, June). Understanding caller-sensitive method
vulnerabilities: A class of access control vulnerabilities in the java platform. In
Proceedings of the 4th ACM SIGPLAN International Workshop on State Of the Art in
Program Analysis (pp. 7-12).
Horstmann, C. S. (2016). Big Java: early objects. John Wiley & Sons.
Sharan, K. (2018). Java remote method invocation. In Java APIs, Extensions and Libraries
(pp. 489-513). Apress, Berkeley, CA.
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]