0% found this document useful (0 votes)
42 views3 pages

Oops Question Set

This document provides code for a C++ program to create a bank account class. The class includes data members for the name, account number, account type, and balance. Member functions are included to assign initial values, deposit an amount, withdraw an amount after checking the balance, and display the name and balance. The main program tests the class by prompting the user for a choice to assign initial values, deposit, withdraw, display details, or exit.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Oops Question Set

This document provides code for a C++ program to create a bank account class. The class includes data members for the name, account number, account type, and balance. Member functions are included to assign initial values, deposit an amount, withdraw an amount after checking the balance, and display the name and balance. The main program tests the class by prompting the user for a choice to assign initial values, deposit, withdraw, display details, or exit.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Write a C++ Program for Bank Account Class

/*Define a class to represent a bank account. Include the following members: Data Members 1 Name of the depositor 2 Account Number 3 Type of account 4 Balance amount in the account Member function 1 To assign initial values 2 To deposit an amount 3 To withdraw an amount after checking the balance 4 To display name and Balance write a main program to test the program. */ #include #include #include class bank { char name[20]; int acno; char actype[20]; int bal; public : void opbal(void); void deposit(void); void withdraw(void); void display(void); };

void bank :: opbal(void) { cout<<<<"Enter Name :-"; cin>>name; cout<<"Enter A/c no. :-"; cin>>acno; cout<<"Enter A/c Type :-"; cin>>actype; cout<<"Enter Opening Balance:-"; cin>>bal; } void bank :: deposit(void) { cout<<"Enter Deposit amount :-"; int deposit=0; cin>>deposit; deposit=deposit+bal; cout<<"\nDeposit Balance = "<<<"\nBalance Amount = "<<<"\nEnter Withdraw Amount :-"; cin>>withdraw; bal=bal-withdraw; cout<<"After Withdraw Balance is "<<<<<<<"DETAILS"<<<<"name "<<<<<"A/c. No. "<<<<<"A/c Type "<<<<<"Balance "<<<<"\n\nChoice List\n\n"; cout<<"1) To assign Initial Value\n"; cout<<"2) To Deposit\n"; cout<<"3) To Withdraw\n"; cout<<"4) To Display All Details\n"; cout<<"5) EXIT\n"; cout<<"Enter your choice :-"; cin>>choice; switch(choice) { case 1: o1.opbal(); break; case 2: o1.deposit(); break; case 3: o1.withdraw(); break; case 4: o1.display(); break; case 5: goto end; } }while(1); end: }

You might also like