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

Problem StatementC

The document outlines the requirements for a simple Bank Account Management System in Java, allowing users to check their balance, deposit, and withdraw money through a user-driven menu. It specifies the necessary variables, methods, and validation conditions for each operation, ensuring proper error handling. The program is designed to continuously display menu options until the user chooses to exit, utilizing a Scanner for user input.

Uploaded by

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

Problem StatementC

The document outlines the requirements for a simple Bank Account Management System in Java, allowing users to check their balance, deposit, and withdraw money through a user-driven menu. It specifies the necessary variables, methods, and validation conditions for each operation, ensuring proper error handling. The program is designed to continuously display menu options until the user chooses to exit, utilizing a Scanner for user input.

Uploaded by

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

Problem Statement: Simple Bank Account Management System.

Objective:
Create a simple Bank Account Management system that allows a user to interactively manage
their bank account( Scanner ) by performing actions such as checking the balance, depositing
money, and withdrawing money ( 3 methods) public void checkbalance(). This program
should be user-driven through a menu ( in java= backend) where they can select one of the
operations to perform on their account.( if -else statement)

Requirements:

1. Bank Account Details: ( variables and datatypes)


o The account has an Account Number (String).
o The account has a Balance (double) which starts with an initial value.

2. Operations: Methods= public void checkbalance(); public void Deposite(); public


void Withdraw();
SWTICH BREAK

The program should present the following operations to the user:

o Check Balance: Display the current account balance. System.put.println(


o Deposit: Allow the user to deposit a certain amount into the account. +
o Withdraw: Allow the user to withdraw a certain amount from the account.
Ensure that the account has sufficient funds before the withdrawal can be
performed. -
o
3. Validation: conditions
o Deposit: Ensure that the deposit amount is positive. If not, print an error
message. (Amount >0)
o Withdrawal: Ensure that the withdrawal amount is valid (positive and not
more than the current balance). If the withdrawal fails, print an error message
for insufficient funds. Balance> amount , else system print error
4. Interactive Menu:
o Continuously display the menu options until the user chooses the option to exit
the program. The menu should allow users to select an option to perform their
chosen operation. (While) or if
5. Exit Option:
o The user should be able to exit the application after performing their desired
operations.
6. package App;
7. import java.util.Scanner;
8.
9. public class Lnkd { // create a class
10.
11. String accountNumber; //
Declare variables with datatype
12. double balance;
13.
14.
15. public Lnkd(String
accountNumber, double balance) {
16. this.accountNumber =
accountNumber;
17. this.balance = balance; ///
constructor created
18. }
19.
20.
21. public void getBalance() { ///
first method
22. System.out.println(balance);
23. }
24.
25. public void deposit(double
amount) { // second method
26. if (amount > 0) {
27. balance = balance +
amount;
28. } else {
29.
System.out.println("Deposit amount
must be positive!");
30. }
31. }
32.
33. public void withdraw(double
amount) { // third method
34. if ( amount <= balance) {
35. balance = balance -
amount;
36. } else {
37.
System.out.println("Insufficient funds or
invalid amount!");
38. }
39. }
40.
41. public static void
main(String[] args) { // main method
42. Scanner scanner = new
Scanner(System.in); // input from user
43.
44. System.out.print("Enter
Account Number: ");
45. String accountNumber =
scanner.nextLine();
46.
47. System.out.print("Enter
Initial Balance: ");
48. double initialBalance =
scanner.nextDouble();
49.
50.
51.
52. Linklds account = new
Linklds(accountNumber, initialBalance);
// object creation
53.
54. while (true) {
55. System.out.println("\
select a transaction");
56. System.out.println("1.
Check Balance");
57. System.out.println("2.
Deposit");
58. System.out.println("3.
Withdraw");
59. System.out.println("4.
Exit");
60.
61. System.out.print("Choose
an option: ");
62. int press =
scanner.nextInt();
63.
64. // Handle menu choices
using if-else conditions
65. if (press == 1) {
66.
System.out.println("Current Balance: " +
account.getBalance());
67. } else if (press == 2) {
68.
System.out.print("Enter deposit amount:
");
69. double amount =
scanner.nextDouble();
70.
account.deposit(amount);
71. } else if (press == 3) {
72.
System.out.print("Enter withdrawal
amount: ");
73. double
withdrawalAmount =
scanner.nextDouble();
74.
account.withdraw(withdrawalAmount);
75. } else if (press == 4) {
76.
System.out.println("Exiting...");
77. break; // Exit the loop
and terminate the program
78. } else {
79.
System.out.println("Invalid option.
Please try again.");
80. }
81. }
82.
83. scanner.close();
84. }
85. }

You might also like