Click here to Skip to main content
15,889,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Create a banking application

The application starts with a welcome message "Welcome to Standard Bank"

The user is then prompted to enter their pin

The user is given 3 chances to enter the pin correctly.

If unsuccessfull on all chances, the program exits with a message "Bye"

If password is entered successfully. The user is shown their initial balance.

A menu is then displayed with the 4 options

==== M E N U =====
 1: View balance
2: Deposit money
3: Withdraw
4: Exit

A user is then prompted to "Please enter your option"

When option 1 is selected - the balance is displayed, and the menu is shown again

When option 2 is selected - the user is prompted to enter the amount they wish to deposit. The amount entered is added to balance, and the menu is shown again

When option 3 is selected and the menu is shown again - the user is prompted to enter the amount they wish to witdraw. The amount entered is deducted from balance. If amount entered is greater than the balance, the user is informed that they have insufficient funds to make that transaction. The menu is shown again

When option 4 is selected - the program exits with a message "You have selected to exit the program. Bye..."


What I have tried:

void main()
{
while (pin != 2025) // Using while loop to check for the condition on a pin number matching
{
printf("Type your secret pin number:");
scanf("%d", &pin);
if (pin != 2025) // Checking if the pin number types by the user is matched with the database record or not
printf("Please insert your valid password:\n");
}
do
{
printf("Hello! Welcome to our ATM Service\n");
printf("1. Balance Checking\n");
printf("2. Cash Withdrawal\n");
printf("3.Cash Deposition\n");
printf("4. Exit\n");
printf("*******?********?*\n\n");
printf("Please proceed with your choice: ");
scanf("%d", &choice);
switch (choice)
{
Posted
Updated 2-Aug-22 2:53am

1 solution

You need a loop that allows only three attempts to enter the pin. After three fails the program should terminate. Your code ignores a failure and just continues. You also need to show the current balance when the user enters a valid pin before showing the menu. And after accepting the menu choice you actually need to do what the remaining instructions tell you.
 
Share this answer
 
Comments
Sidima Ngada 2-Aug-22 9:05am    
Which loop can i use to give the user 3 chances to enter the pin correctly?
KarstenK 2-Aug-22 9:21am    
use a counter of that. Dont ferget to reset it in success case.
Sidima Ngada 3-Aug-22 6:28am    
Thank you
Richard MacCutchan 2-Aug-22 9:21am    
Any loop, as lo ng as you include a counter.
for (int i = 0; i < 3; i++)
{
}
//
int counter = 0;
while (counter < 3)
{
//
    counter++;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900