Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Define a class to represent a bank account. Include the
following
members:
Data Members:
Name of the Depositor
Account Number
Type of Account
Balance amount in the account

Member Functions:
To assign the initial values.
To deposit an account.
To withdraw an amount after checking the balance.

Write a C++ main program to display account number,
name and
balance.

Answer Posted / prashant kumar

#include<iostream>
#include<stdio.h>
#include<string.h>

using namespace std;

class bank
{
int acno;
char nm[100], acctype[100];
float bal;
public:
bank(int acc_no, char *name, char *acc_type, float balance) //Parameterized Constructor
{
acno=acc_no;
strcpy(nm, name);
strcpy(acctype, acc_type);
bal=balance;
}
void deposit();
void withdraw();
void display();
};
void bank::deposit() //depositing an amount
{
int damt1;
cout<<"
Enter Deposit Amount = ";
cin>>damt1;
bal+=damt1;
}
void bank::withdraw() //withdrawing an amount
{
int wamt1;
cout<<"
Enter Withdraw Amount = ";
cin>>wamt1;
if(wamt1>bal)
cout<<"
Cannot Withdraw Amount";
bal-=wamt1;
}
void bank::display() //displaying the details
{
cout<<"
----------------------";
cout<<"
Accout No. : "<<acno;
cout<<"
Name : "<<nm;
cout<<"
Account Type : "<<acctype;
cout<<"
Balance : "<<bal;
}
int main()
{
int acc_no;
char name[100], acc_type[100];
float balance;
cout<<"
Enter Details:
";
cout<<"-----------------------";
cout<<"
Accout No. ";
cin>>acc_no;
cout<<"
Name : ";
cin>>name;
cout<<"
Account Type : ";
cin>>acc_type;
cout<<"
Balance : ";
cin>>balance;

bank b1(acc_no, name, acc_type, balance); //object is created
b1.deposit(); //
b1.withdraw(); // calling member functions
b1.display(); //
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

1169


Why is polymorphism used?

995


Which is better struts or spring?

988


What are two types of polymorphism?

1014


How to call a non virtual function in the derived class by using base class pointer

6420


if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?

3407


Can private class be inherited?

1120


Is oop better than procedural?

976


Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

1241


Write a c++ program to display pass and fail for three student using static member function

3326


What is the full form of oops?

1121


What is persistence in oop?

1094


#include #include #include #include void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

2564


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

2042


Why we use classes in oop?

977