C program for bank account, C/C++ Programming

Assignment Help:

Aim: To implement a program for bank account using static data type.

Code:

class bank

{

            static int acc_no;

            int acc;

            float bal;

            public:

            int open_ac(float b)

            {

                        acc_no++;

                        acc=acc_no;

                        bal=b;

                        return(acc_no);

            }

            void deposit()

            {

                        int am;

                        cout<<"Enter amount: Rs.";

                        cin>>am;

                        bal=bal+am;

                        cout<<"Amount Deposited!\nNew Balance: Rs. "<

            }

            void withdrawl()

            {

                        int am;

                        cout<<"Enter amount: Rs.";

                        cin>>am;

                        if(bal<(am+500))

                                    cout<<"Sorry! transaction can not be processed. Balance not available.";

                        else

                        {

                                    bal=bal-am;

                                    cout<<"Amount withdrawn.";

                                    cout<

                        }

            }

};

int bank :: acc_no=99;

void main()

{

            int c,x=0,b,id;

 

            clrscr();

            bank cust[5];

            cout<<"BANK DATABASE";

            do

            {

                        cout<<"\n1. Create A/c.\n2. Deposit\n3. Withdrawl\n4. Exit";

                        cout<<"\n\nEnter your choice:";

                        cin>>c;

                        switch(c)

                        {

                                    case 1:

                                    cout<

                                    cin>>b;

                                    id=cust[x].open_ac(b);

                                    x++;

                                    cout<<"You a/c is opened! A/c No. "<

                                    break;

 

                                    case 2:

                                    cout<<"Enter A/c No. for deposit:";

                                    cin>>id;

                                    if(id>(x+99))

                                    {

                                                cout<<"Wrong A/c no.";

                                                break;

                                    }

                                    cust[id-100].deposit();

                                    break;

 

                                    case 3:

                                    cout<<"Enter A/c No. for withdrawl:";

                                    cin>>id;

                                    if(id>(x+99))

                                    {

                                                cout<<"Wrong A/c no.";

                                                break;

                                    }

                                    cust[id-100].withdrawl();

                                    break;

 

                                    case 4:

                                    exit(1);

                                    break;

                        }

 

            }while(x<=4);

            getch();

}

 

Output:

BANK DATABASE

1. Create A/c.

2. Deposit

3. Withdrawl

4. Exit

Enter your choice:1

Enter balance:4000

You a/c is opened! A/c No. 100

1. Create A/c.

2. Deposit

3. Withdrawl

4. Exit

 

Enter your choice:2

Enter A/c No. for deposit:100

Enter amount: Rs.800

Amount Deposited!

New Balance: Rs. 4800

1. Create A/c.

2. Deposit

3. Withdrawl

4. Exit

 

Enter your choice:3

Enter A/c No. for withdrawl:100

Enter amount: Rs.900

Amount withdrawn.

Balance: Rs.3900

1. Create A/c.

2. Deposit

3. Withdrawl

4. Exit

Enter your choice:4


Related Discussions:- C program for bank account

Create a programming system, Your task is to create a programming system fo...

Your task is to create a programming system for a ferry. The ferry transports passengers and vehicles (cars, busses, lorries and bicycles). The ferry has space for 200 passengers a

Explain the function of five elements that are on a, explain the function o...

explain the function of five elements that are found on a motherboard#

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Virtual memory implementation, I need help with virtual memory manager impl...

I need help with virtual memory manager implementation in C

Common concepts of object oriented, Object Oriented Programming Paradigm: ...

Object Oriented Programming Paradigm: For OOP, Paradigm is a standard set.  The OOP will help to develop software in modules, which will be integrated later as a full packag

Design a car management system application, 1) Database: The database nee...

1) Database: The database needs to be used for persistent storage of cars. For details of what information should be stored in the database, please see the description above. You

Last ant on rod, There are ''n'' ants on a ''n+1'' length rod. The ants are...

There are ''n'' ants on a ''n+1'' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are moving eith

How to write Bernoulli''s principle, compose a C program to solve the equat...

compose a C program to solve the equation z2=(p1/Pg)+(v1^2/2g)+z1 p1=100kpa,v1=2m/s z1=3m P=1000kg/m^3 define g=9.81

Implementation of the stack class in c++, Implementation of the Stack class...

Implementation of the Stack class in C++: How to implement stack class in c++. int Stack::push(int elem) {    if (top    {       list[top++] = elem;       r

Simple text editor using c programming in linux environment, Deliverables: ...

Deliverables: you are required to upload your c code in the assignment dropbox set in Moodle. You are supposed to work with Linux gcc compiler and pico editor for compiling via the

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd