Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners c++ program of inheritance
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ridhima sehgal
c++ program of inheritance
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed. Create a class account that stores customer name, account number and type of account. From this derive the classes curacct and savacct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks: (a) Accept deposit from a costumer and update the balance.

(b) Display the balance

(c) Compute and deposit interest.

(d) Permit withdrawal and update the balance.

Check for the minimum balance, impose penalty, necessary, and update the balance.


Advertisement
View Answers

April 27, 2012 at 5:34 PM


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

class account{

protected:
      char cname[20];
      int accno;
      char type;
      int bal;
public:
      account()
      {
        strcpy(cname," ");
        accno=0;
        type=' ';
        bal=0;
      }
      void input(){
        cout<<"Enter cname";cin>>cname;
        cout<<"Enter accno";cin>>accno;
        fflush(stdin);
        cout<<"Enter type"; cin>>type;
        fflush(stdin);
        cout<<"Enter bal";cin>>bal;
      }
      void display(){
            cout<<"\n Customer Name "<<cname;
            cout<<"\n Account Number "<<accno;
            cout<<"\n Type "<<type;
            cout<<"\n Balance "<<bal;
      }
      void deposit(){
            int amt;
            cout<<"\n Enter the amount to deposit";
            cin>>amt;
            bal=bal+amt;
      }
};
class savacct:public account{
      int inter;
      public:

      int comp_int(){
         int time1,rate1;
         rate1=10;
         cout<<"\n Enter time";cin>>time1;
         inter=bal*pow(1+rate1/100.0,time1)-bal;
         return inter;
      }

      void update_bal(){
         bal=bal+comp_int();
      }

      void withdrawal(){
         int amt;
         cout<<"\n Enter amount to withdrawn";
         cin>>amt;
         if(bal>=amt){
               bal=bal-amt;
         }
         else{
               cout<<"\n The amount cannot be withdrawn";
         }
      }
  };

class curacct:public account{
       int chq_bk;
       int penal;
       public:

       int min_bal(){
          int ret1=1;
          if(bal<=500){
             penal=50;
             bal=bal-penal;
             ret1=0;
          }
          else{
             cout<<"\n No penality imposed";
          }
          return ret1;
      }
      void withdrawal(){
          int amt;
          cout<<"\n Enter the amount to withdrawn";
          cin>>amt;
          int k=min_bal();
          if(k==1){
             if(bal>=amt)
             bal=bal-amt;
          }
          else{
              cout<<"\n The amount cannot be withdrawn";
          }
      }
   };

void main(){
      curacct c1;
      savacct s1;
      c1.input();
      c1.display();
      c1.deposit();
      c1.display();
      c1.withdrawal();
      c1.display();
      s1.input();
      s1.display();
      s1.deposit();
      s1.display();
      s1.withdrawal();
      s1.display();
}


Related Tutorials/Questions & Answers:
c++ program of inheritance
c++ program of inheritance   Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current.... (b) Display the balance (c) Compute and deposit interest. (d) Permit
doubt in inheritance program - Java Beginners
doubt in inheritance program  how will we get the result 6 2 5 in the inheritance program in the given example i got 6 &2 but i am confused about 5
Advertisements
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
c++ program
c++ program  Write a program which reads a text from the keyboard and displays the following information on the screen in two columns: (a) Number of lines (b) Number of words (c) Number of characters Strings should be left
c program
c program  plz send me program for this. write a program to print the following code? (in c language) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10
c program
c program  plz send me program for this. write a program to print the following code? 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 12 3 4
C Program
C Program  Why doesn't the code int a = 1000, b = 1000; long int c = a * b; work? plz help me sir
c program
c program  WAP to show the area of a perimeter of a rectanglar by using input command
c program
c program  How to convert binary digits to decimal number without using power function
C program
C program  hi, here is my question: Create a structure to specify data on students given below: Roll number, Name,Department, Course, Year... a function to print names of all students who joined in a particular year. (c
program in c
program in c  Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement. For example: 1 3
inheritance code program - Java Beginners
inheritance code program  class Point { private int x ; private int y; public Point (int x , int y) { this.x = x; this.y =y... QUADRANT IF ITS 1,2,3,4 QUADRANT. EXAMPLE OUTPUT: Using inheritance example
Objective-C Inheritance
Objective-C Inheritance       Objective-C enables programmer to inherit common methods and properties from other class, known as inheritance. Class from
method overloading in c program
method overloading in c program  how is method overloading in C program is different from C++ program
malloc in c example program
malloc in c example program  What is malloc in c? Please explain the term using an example in C program. Thanks
C Program with Database Connectivity
C Program with Database Connectivity  How To Connect MySQL Database in C Program with Graphics
c program - Java Beginners
c program  Write a program to encrypt a string and decrypt
C program - SQL
C program  Write a C program for airport simulation using queue data structures. Please reply me
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334..., that is why I choosed Java Beginners, but please give me a C program
c program - IoC
c program  given the string "wordprocessing",write a program to read the string from the terminal and display the same in the following formats: a) word processing b) word processing c) w.p.
c program - Java Beginners
c program  1. How to write a program to Add 2 numbers without using int .size should be more than machine size
C Program - Development process
C Program  C program to find division of two fraction number without...: #include #include #include int main () { int a; int b; int c; int... in the form a/b: "); scanf("%d/%d", &c, &d); nr=a*d; dr=b*c; printf("%d/%d",nr,dr
C program - Java Magazine
C program  develop a simple program in C that allows a user to enter... and then the program; a)First determines whether the 3 integers entered represent the sides..., the program should print the following; The three integers form a Right-angled
inheritance
inheritance  how does one implement inheritance in java
C program - SQL
C program  write a C program to print multiplication table using pointers.  Hi Friend, Try the following code: #include #include void main() { int i,j; int * pt; clrscr(); printf(" "); printf("\n
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
C Programming SubString Program
C Programming SubString Program  Sir I want to Check whether the Single Substring is present in the given 3 string. characters. eg if i entered... entered to check PROGRAM is exists in given three strings then output
C++ program not running
C++ program not running  Hi, this program need to ask 10 random questions with a random month name. Example: RUN How many days are there in the month of March? 28 No March has 31 days. How many days are there in the month
C Program....PLEASE HELP
C Program....PLEASE HELP  For this assignment, you are to write a program that calculates points along a rhodonea curve, a.k.a. a mathematical rose, and produces a simple character plot of the results, using functions, arrays
C program - SQL
C program  Thank You . Write some C programs using pointers . Write some C programs using files. Please reply me .   Hi Friend, Please visit the following link: http://www.roseindia.net/c
Inheritance program in java
Inheritance: class A { int x; int y; int get(int p, int q){ x=p; y=q; return(0...In this tutorial we will discuss examples of Simple Inheritance in Java and Multilevel Inheritance in Java. Inheritance is an OOPS (Object Oriented
Advertisements
 

 

 

DMCA.com