Question

Lance 1. Write a C++ program that manages a users bank account. The program must but not limited to: (a) Display a menu for

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the solution to above problem in C++. Please read the code comments for more information

Give a thumbs up!!!

C++ Code

#include<iostream>
#include<string>
using namespace std;


//class for an account
class Account
{
   string fname;
   string lname;
   double balance;
   int accno;
   string password;
   public:
       //constructor
       Account()
       {
       fname="";
       lname="";
       balance=0;
       accno=0;
       password="A*B4";  
       }
       //parametrized constructor
       Account(string f,string l,double b,const string p,int acc)
       {
           fname=f;
           lname=l;
           balance=b;
           password=p;
           accno=acc;
       }
       //to get balance
       double getBalance()
       {
           return balance;
       }
       //deposit amount
       void deposit(double amount)
       {
           balance+=amount;  
       }      
       //withdraw
       void withdraw(double amount)
       {
           balance-=amount;
       }
};

int main()
{
  
   int choice=0;
   Account *A; // object pointer for account
   //get user info
   string fname,lname;
   int acc;
   double balance;
   string password;
   cout<<"Enter First name: ";
   cin>>fname;
   cout<<"Enter Last name: ";
   cin>>lname;
   cout<<"Enter Account Number : ";
   cin>>acc;
   cout<<"Enter Password: ";
   cin>>password;
   //create a new account
   A= new Account(fname,lname,0,password,acc);
   //display the menu to the user
   while(choice!=5)
   {
       cout<<"1.Cash Withdrawal\n";
       cout<<"2.Quick Withdrawal\n";
       cout<<"3.Cash Deposit\n";
       cout<<"4.Show Balance\n";
       cout<<"5.Exit\n";
       cout<<"Enter your choice: ";
       cin>>choice;
       switch(choice)
       {
           case 1:
               {
                   double amount;
                   cout<<"Enter the amount less than 1000K.D\n";
                   cin>>amount;
                   if(A->getBalance()<amount) //check if balance is insufficient
                   {
                       cout<<"BALANCE INSUFFICIENT\n";
                   }
                   else
                       A->withdraw(amount);
               }
               break;
           case 2:
               { //quick withdraw
                   char c;
                   cout<<"a: K.D. 50\n";
                   cout<<"b: K.D. 100\n";
                   cout<<"c: K.D. 250\n";
                   cout<<"d: K.D. 500\n";
                   cout<<"Enter choice: ";
                   cin>>c;
                   switch(c)
                   {
                       case 'a': A->withdraw(50);
                       break;
                       case 'b': A->withdraw(100);
                       break;
                       case 'c': A->withdraw(250);
                       break;
                       case 'd': A->withdraw(500);
                       break;
                      
                   }
                   break;
               case 3:
                   {
                   double amount;
                   cout<<"Enter the amount: ";
                   cin>>amount;
                   A->deposit(amount);
                   }
                   break;
               case 4:
                   {
                       cout<<"YOUR BALANCE IS: "<<A->getBalance()<<endl;
                   }
                   break;
               case 5:break;
               }
           default: cout<<"Enter a valid choice\n";
       }
   }
   return 0;
}

Screenshot of output

Enter First name: John Enter Last name: Doe Enter Account Number : 12357 Enter Password: Alpha 1.Cash Withdrawal 2. Quick Wit

Add a comment
Know the answer?
Add Answer to:
Lance 1. Write a C++ program that manages a user's bank account. The program must but...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Banking System (Java Programming) 1 bank (Bank) has 5 accounts holder (Account) also designing te...

    Banking System (Java Programming) 1 bank (Bank) has 5 accounts holder (Account) also designing textbased menu (switch case): Main Menu: 1. Admin Login 2. User Login 3. Exit Admin Menu: 1. Add an Account 2. Remove an Account 3. Print total balance 4. Print total balance per city 5. Go back to main menu User Login 1. Withdraw //also redo last withdraw 2. Deposit //also redo last deposit 3. print account 4. Go back to main menu Designing class Account...

  • C++ Read and do as instructed on please (C++Program *** use only condition statements, loops, functions,...

    C++ Read and do as instructed on please (C++Program *** use only condition statements, loops, functions, files, and arrays. Do NOT use material such as classes. Make sure to add comments** You are to write an ATM Program. The ATM should allow the user to do the following: 1. Create account 2. Log in 3. Exit When they press 1, they are asked for first name (capital first letter). Then it should ask for password. The computer should give the...

  • this is for java programming Please use comments Use the Account class created in homework 8_2...

    this is for java programming Please use comments Use the Account class created in homework 8_2 to simulate an ATM machine. Create ten checking accounts in an array with id 0, 1, …, 9, initial balance of $100, and annualInterestRate of 0. The system prompts the user to enter an id between 0 and 9, or 999 to exit the program. If the id is invalid (not an integer between 0 and 9), ask the user to enter a valid...

  • On Dev C++ Write a C++ program that read customer name and saving account balance. Then...

    On Dev C++ Write a C++ program that read customer name and saving account balance. Then it display the following messages to the user: "Press #1 to make a deposit." "Press #2 to make withdraw." If the user presses "1", then read the amount of the deposit, apply it to the balance and display the new account balance. If the user presses "2", then read the amount to withdraw, apply it to the balance and display the new account balance....

  • 1- TigerOne Bank is a local bank that intends to install a new automated teller machine...

    1- TigerOne Bank is a local bank that intends to install a new automated teller machine (ATM) to allow its customers to perform basic financial transactions. Using the ATM machine users should be able to view their account balance, withdraw cash and deposit funds. The bank wants you to develop the software application that will be installed on the new ATM machines. The following are the requirements for the application:  Users are uniquely identified by an account number and...

  • 8. (15 marks) Write a complete C program, which uses an array of structures and two...

    8. (15 marks) Write a complete C program, which uses an array of structures and two user defined functions. The program deals with a library database. The program will ask the user to input required information about each book and store it in a structure in a user defined function called get info. The second user defined function display_info will display database information on the screen. The output should look as follows: Book Title Book ld 123456 C Programming 10...

  • Question 3.1 Draw the class diagram for the ATM program in Question 2.1. Please find attached...

    Question 3.1 Draw the class diagram for the ATM program in Question 2.1. Please find attached the scenario in the photos. this is for programming logic and design Scenario A local bank intends to install a new automated teller machine (ATM) to allow users (i.e., bank customers) to perform basic financial transactions (see below figure). Each user can have only one account at the bank. ATM users should be able to do the following; View their account balance. Withdraw cash...

  • •create a new savings account object (for choice 2). •ask the user to enter an initial...

    •create a new savings account object (for choice 2). •ask the user to enter an initial balance which should be greater than 50. If the entered amount is less than 50, the program will ask the user to enter another amount. This continues until an amount greater than 50 is entered. •Set the balance of the savings account object by calling the setBalance() method. •Ask the user to deposit an amount. Deposit that amount and display the balance of the...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • 1. Write a C++ program called Password that handles encrypting a password. 2. The program must...

    1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT