SlideShare a Scribd company logo
1 of 18
OBJECT ORIENTED PROGRAMMINGS 2010




Q 1) 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.




 1|Page
OBJECT ORIENTED PROGRAMMINGS 2010



#include<iostream.h>
#include<conio.h> //for clrscr()
#include<stdio.h> //for gets()
#include<iomanip.h>
const int LEN=30;
const int max=100;
class members
{ private:
 char name[LEN];
 unsigned long bal_amount;
 char acctype[LEN];
 public:
 unsigned long accnumb;
 members()
 { bal_amount =1000000;
 }
 void getdata()
 { cout<<"Enter Name:"<<endl;
   gets(name);
   cout<<"Enter AccountNo:"<<endl;
   cin>>accnumb;
   cout<<"Enter the Account-type:"<<endl;
   gets(acctype);
   cout<<"Enter the balance amount:"<<endl;
   cin>>bal_amount;
 }
 void putdata()
 { cout<<"Name: "<<name<<"t";
   cout<<"AccountNo: "<<accnumb<<"t";
   cout<<"Account Type: "<<acctype<<"t";
   cout<<"Balance Amount: "<<bal_amount<<"t";
   cout<<endl;
 }
 void withdraw()
 { unsigned long wdraw_amount;
   cout<<"Enter the amount U want to withdraw: t";
   cin>>wdraw_amount;
   cout<<endl;
   if(wdraw_amount>bal_amount || wdraw_amount%100!=0)
   { cout<<"U have entered the wrong amount."<<endl;
     cout<<"Amount less than balance and multiple of 100 only can be
withdrawn"<<endl;
     wdraw_amount=0;
   }
   else
2|Page
OBJECT ORIENTED PROGRAMMINGS 2010


  bal_amount= bal_amount-wdraw_amount;
  cout<<"Amount withdrawn: t"<<wdraw_amount<<"t";
  cout<<"Balance: t"<<bal_amount<<"t"<<endl;
  }
  void check_balance()
  {
    cout<<"Balance: t"<<bal_amount<<endl;
  }
  void deposit_amount()
  { unsigned long d_amount;
    cout<<"Enter the amount U want to deposit: t";
    cin>>d_amount;
    cout<<endl;
    bal_amount=bal_amount+d_amount;
    cout<<"Balance: t"<<bal_amount<<endl;
  }
};
void main()
{
 clrscr();
 members m[max];
 unsigned long acc_no;
 int n;
 cout<<"The no of records U want 2 be entered: t"<<endl;
 cin>>n;
 cout<<"Enter the following Records"<<endl;
 for (int i=0;i<n;++i)
 {
  cout<<"Record:t"<<i+1<<endl;
  m[i].getdata();
 }
 clrscr();
 for (i=0; i<n; ++i)
 {cout<<"Record "<<i+1<<endl;
  m[i].putdata();
 }
 char ch;
 cout<<"Do u want 2 continue for any account?"<<endl;
 cin>>ch;
 clrscr();
 while(ch=='y')
 {
  cout<<"Enter ur account not"<<endl;
  cin>>acc_no;
  for(i=0; i<n; i++)
  { if(acc_no==m[i].accnumb)
    { int opt;
3|Page
OBJECT ORIENTED PROGRAMMINGS 2010


     m[i].putdata();
     char ans;
     cout<<"Do U want 2 continue for any account-process(y/n)?t";
     cin>>ans;
     cout<<endl;
     while(ans=='y')
     {
        cout<<"Enter ur option (1-check balance, 2-deposit, 3-withdraw)"<<endl;
        cin>>opt;
        cout<<endl;
        switch(opt)
        { case 1: m[i].check_balance();
                   break;
           case 2: m[i].deposit_amount();
                   break;
           case 3: m[i].withdraw();
                   break;
           deafault: cout<<"Wrong Option"<<endl;
         }
         cout<<"Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?"<<endl;
         cin>>ans;
         cout<<endl;
        }
      }
     }
   cout<<"Do U want 2 continue for any other account?"<<endl;
   cin>>ch;
   }
   getch();
  }




OUTPUT
The no of records U want 2 be entered:
3
Enter the following Records
Record     1
Name:
Sarvesh
Enter Account No:
123456
Enter the Account-type:
Current
Enter the balance amount:
91234567

4|Page
OBJECT ORIENTED PROGRAMMINGS 2010


Record     2
Name:
Prashant
Enter Account No:
456789
Enter the Account-type:
Saving
Enter the balance amount:
90234567
Record     3
Name:
Rajeev
Enter Account No:
789012
Enter the Account-type:
Current
Enter the balance amount:
98765432

Clear-screen..............

Record    1
Name: Sarvesh       Account No: 123456         Account-type: Current      Balance amount: 91234567
Record    2
Name: Prashant        Account No: 456789       Account-type: Saving       Balance amount: 90234567
Record    3
Name: Rajeev          Account No: 789012       Account-type: Current      Balance amount: 98765432
Do u want 2 continue for any account?
y

Clear-screen...

Enter ur account no
789012
Name: Rajeev           Account No: 789012         Account-type: Current   Balance amount: 98765432
Do U want 2 continue for any account-process(y/n)? y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
1
Balance: 98765432
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
2
Enter the amount U want to deposit: 67890543
Balance: 166655975
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
3
Enter the amount U want to withdraw: 4567890
U have entered the wrong amount.
Amount less than balance and multiple of 100 only can be withdrawn
Amount withdrawn:           0        Balance: 166655975
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
5|Page
OBJECT ORIENTED PROGRAMMINGS 2010


3
Enter the amount U want to withdraw: 4567800
Amount withdrawn:      4567800         Balance:        162088175
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
n
Do U want 2 continue for any other account?
n




        Q 2) Write an operator overloading program to write S3+=S2.




6|Page
OBJECT ORIENTED PROGRAMMINGS 2010




#include<iostream.h>
#include<conio.h>
class numb
{ private:
  int i;
  public:
  numb()
  { i=10;
  }
  void operator++()
  { i=i+1;
    cout<<i<<endl;
  }
};
void main()
{ numb n;
  clrscr();
  int j;
  cout<<"How many times u want to increment the value?t";
  cin>>j;
  for(int m=0;m<j;++m)
  {n.operator++();
  }
  getch();
}


OUTPUT
7|Page
OBJECT ORIENTED PROGRAMMINGS 2010


How many times u want to increment the value? 8
11
12
13
14
15
16
17
18




// overloading prefix ++ incrementer operator for obtaining Fibonacci series
#include<iostream.h>
#include<conio.h>
class fibonacci
{ private:
  unsigned long int f0, f1, fib;
  public:
  fibonacci(); //constructor
  void operator++();
  void display();
};
fibonacci::fibonacci()
{ f0=0;
  f1=1;
  fib=f0+f1;
}
void fibonacci::display()
{ cout<<fib<<"t";
}
void fibonacci::operator++()
{f0=f1;
 f1=fib;
 fib=f0+f1;
}

8|Page
OBJECT ORIENTED PROGRAMMINGS 2010


void main()
{
clrscr();
fibonacci obj;
int n;
cout<<"How many fibonacci numbers are to be displayed? n";
cin>>n;
for(int i=0; i<=n-1;++i)
{
obj.display();
++obj;
}
getch();
}


OUTPUT

How many fibonacci numbers are to be displayed?

10

1    2     3     5     8     13      21     34    55   89




Q 3) Write an operator overloading program to Overload ‘>’ operator so as to
find greater among two instances of the class.
9|Page
OBJECT ORIENTED PROGRAMMINGS 2010




//overloading of comparison operators
#include<iostream.h>
#include<conio.h>
class sample
{ private:
          int value;
  public:
          sample();
          sample( int one);
          void display();
          int operator > (sample obj);
};
sample::sample()
{
 value = 0;
 }
sample::sample( int one)
10 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 value = one;
}
void sample::display()
{
 cout<<"value "<<value<<endl;
}
int sample::operator > (sample obja)
{
 return (value > obja.value);
}
void main()
{
 clrscr();
 sample obja(20);
 sample objb(100);
 cout<<(obja>objb)<<endl;
 cout<<(objb>obja)<<endl;
 getch();
}


OUTPUT

0

1




11 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010




                  Q 4) WAP using Single and Multiple Inheritance.




//single inheritance using array of objects
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iomanip.h>
const int max=100;
class basic_info
{
 private: char name[30];
          long int rollno;
          char sex;
 public: void getdata();
          void display();
}; //end of class declaration
class physical_fit:public basic_info
{
 private: float height,weight;
 public: void getdata();
         void display();
};
void basic_info::getdata()
12 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 cout<<"ENTER A NAME ? n";
 cin>>name;
 cout<<"ROLL No. ? n";
 cin>>rollno;
 cout<<"SEX ? n";
 cin>>sex;
}
void basic_info::display()
{
 cout<<name<<"        ";
 cout<<rollno<<"       ";
 cout<<sex<<"      ";
}
void physical_fit::getdata()
{
 basic_info::getdata();
 cout<<"HEIGHT ? n";
 cin>>height;
 cout<<"WEIGHT ? n";
 cin>>weight;
}
void physical_fit::display()
{
 basic_info::display();
 cout<<setprecision(2);
 cout<<height<<" ";
 cout<<weight<<"        ";
}
void main()
{
 clrscr();
 physical_fit a[max];
 int i,n;
 cout<<"HOW MANY STUDENTS ? n";
 cin>>n;
 cout<<"ENTER THE FOLLOWING INFORMATION n";
 for(i=0;i<=n-1;++i)
 {
  cout<<"RECORD : "<<i+1<<endl;
  a[i].getdata();
 }
 cout<<endl;
 cout<<"_________________________________________________ n";
 cout<<"NAME ROLLNO SEX HEIGHT WEIGHT n";
 cout<<"_________________________________________________ n";
 for(i=0;i<=n-1;++i)
13 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


 {
  a[i].display();
  cout<<endl;
 }
 cout<<endl;
 cout<<"_________________________________________________ n";
 getch();
}




OUTPUT

HOW MANY STUDENTS?
3
ENTER THE FOLLOWING INFORMATION
RECORD: 1
ENTER A NAME?
Sarvesh
ROLL No. ?
13
 SEX?
M
 HEIGHT?
174
WEIGHT?
59
RECORD : 2
ENTER A NAME?
Prashant
ROLL No. ?
19
 SEX ?
M
 HEIGHT?
166
WEIGHT?
63
RECORD : 3
ENTER A NAME ?
Rajeev
ROLL No. ?
23
 SEX ?
M
 HEIGHT?
14 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


164
WEIGHT?
53

_________________________________________________
 NAME         ROLLNO SEX HEIGHT WEIGHT
 _________________________________________________

Sarvesh        13        M       174       59

Prashant       19        M       166       63

Rajeev          23       M       164       53

_________________________________________________




#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class baseA
{
 public: int a;
};
class baseB
{
 public: int a;
};

15 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


class baseC
{
 public: int a;
};
class derivedD: public baseA,public baseB, public baseC
{
 public: int a;
};
void main()
{
 clrscr();
 derivedD objd;
 objd.a=10; //local to the derived class
 cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a;
 cout<<endl;
 cout<<endl;
 getch();
}




#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class baseA
{
 public: int a;
};
class baseB
16 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 public: int a;
};
class baseC
{
 public: int a;
};
class derivedD: public baseA,public baseB, public baseC
{
 public: int a;
};
void main()
{
 clrscr();
 derivedD objd;
 objd.a=10;
 objd.baseA::a=20;
 objd.baseB::a=30;
 objd.baseC::a=40;
 cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a;
 cout<<endl;
 cout<<endl;
 getch();
}




OUTPUT


VALUE OF a IN THE DERIVED CLASS = 10
VALUE OF a IN THE baseA = 20
VALUE OF a IN THE baseB = 30

17 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


VALUE OF a IN THE baseC = 40




18 | P a g e

More Related Content

What's hot

Oops practical file
Oops practical fileOops practical file
Oops practical file
Ankit Dixit
 
Travel management
Travel managementTravel management
Travel management
1Parimal2
 

What's hot (20)

Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Ss
SsSs
Ss
 
C programs
C programsC programs
C programs
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
 
Travel management
Travel managementTravel management
Travel management
 
Function basics
Function basicsFunction basics
Function basics
 
Implementing string
Implementing stringImplementing string
Implementing string
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final Project
 
Cquestions
Cquestions Cquestions
Cquestions
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
Informatics Practice Practical for 12th class
Informatics Practice Practical for 12th classInformatics Practice Practical for 12th class
Informatics Practice Practical for 12th class
 

Viewers also liked (20)

IPR
IPRIPR
IPR
 
Inventory management
Inventory managementInventory management
Inventory management
 
Order specification sheet
Order specification sheetOrder specification sheet
Order specification sheet
 
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
 
Human resource management
Human resource managementHuman resource management
Human resource management
 
Customer relationship management
Customer relationship managementCustomer relationship management
Customer relationship management
 
Calculator code
Calculator codeCalculator code
Calculator code
 
P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )
 
RECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENTRECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENT
 
Production and materials management
Production and materials managementProduction and materials management
Production and materials management
 
Final pl doc
Final pl docFinal pl doc
Final pl doc
 
Ergonomics
Ergonomics Ergonomics
Ergonomics
 
Material requirement planning
Material requirement planningMaterial requirement planning
Material requirement planning
 
SETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRYSETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRY
 
Shirt spec sheet
Shirt spec sheetShirt spec sheet
Shirt spec sheet
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
PAD FINAL DOC
PAD FINAL DOCPAD FINAL DOC
PAD FINAL DOC
 
Sp 02
Sp 02Sp 02
Sp 02
 
Sp 02
Sp 02Sp 02
Sp 02
 
Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2
 

Similar to Rajeev oops 2nd march

This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdf
kavithaarp
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
Aayush Mittal
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
Aayush Mittal
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
pnaran46
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
JUSTSTYLISH3B2MOHALI
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf
ANJANEYAINTERIOURGAL
 

Similar to Rajeev oops 2nd march (20)

This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdf
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Statement
StatementStatement
Statement
 
project
projectproject
project
 
C++ coding for Banking System program
C++ coding for Banking System programC++ coding for Banking System program
C++ coding for Banking System program
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ project
C++ projectC++ project
C++ project
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf
 
Ch 4
Ch 4Ch 4
Ch 4
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 

More from Rajeev Sharan

More from Rajeev Sharan (20)

Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
Production module-ERP
Production module-ERPProduction module-ERP
Production module-ERP
 
Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
E smartx.ppt
E smartx.pptE smartx.ppt
E smartx.ppt
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
product analysis & development- sourcing
product analysis & development- sourcingproduct analysis & development- sourcing
product analysis & development- sourcing
 
Product Analysis & Development
Product Analysis & DevelopmentProduct Analysis & Development
Product Analysis & Development
 
Ergonomics
ErgonomicsErgonomics
Ergonomics
 
Total service management
Total service managementTotal service management
Total service management
 
Lean- automobile
Lean- automobileLean- automobile
Lean- automobile
 
Vb (2)
Vb (2)Vb (2)
Vb (2)
 
Vb (1)
Vb (1)Vb (1)
Vb (1)
 
Vb
VbVb
Vb
 
INVENTORY OPTIMIZATION
INVENTORY OPTIMIZATIONINVENTORY OPTIMIZATION
INVENTORY OPTIMIZATION
 
Professional practices
Professional practicesProfessional practices
Professional practices
 
Report writing.....
Report writing.....Report writing.....
Report writing.....
 
Business ethics @ tata
Business ethics @ tataBusiness ethics @ tata
Business ethics @ tata
 
Software maintenance
Software maintenance Software maintenance
Software maintenance
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assurance
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 

Rajeev oops 2nd march

  • 1. OBJECT ORIENTED PROGRAMMINGS 2010 Q 1) 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. 1|Page
  • 2. OBJECT ORIENTED PROGRAMMINGS 2010 #include<iostream.h> #include<conio.h> //for clrscr() #include<stdio.h> //for gets() #include<iomanip.h> const int LEN=30; const int max=100; class members { private: char name[LEN]; unsigned long bal_amount; char acctype[LEN]; public: unsigned long accnumb; members() { bal_amount =1000000; } void getdata() { cout<<"Enter Name:"<<endl; gets(name); cout<<"Enter AccountNo:"<<endl; cin>>accnumb; cout<<"Enter the Account-type:"<<endl; gets(acctype); cout<<"Enter the balance amount:"<<endl; cin>>bal_amount; } void putdata() { cout<<"Name: "<<name<<"t"; cout<<"AccountNo: "<<accnumb<<"t"; cout<<"Account Type: "<<acctype<<"t"; cout<<"Balance Amount: "<<bal_amount<<"t"; cout<<endl; } void withdraw() { unsigned long wdraw_amount; cout<<"Enter the amount U want to withdraw: t"; cin>>wdraw_amount; cout<<endl; if(wdraw_amount>bal_amount || wdraw_amount%100!=0) { cout<<"U have entered the wrong amount."<<endl; cout<<"Amount less than balance and multiple of 100 only can be withdrawn"<<endl; wdraw_amount=0; } else 2|Page
  • 3. OBJECT ORIENTED PROGRAMMINGS 2010 bal_amount= bal_amount-wdraw_amount; cout<<"Amount withdrawn: t"<<wdraw_amount<<"t"; cout<<"Balance: t"<<bal_amount<<"t"<<endl; } void check_balance() { cout<<"Balance: t"<<bal_amount<<endl; } void deposit_amount() { unsigned long d_amount; cout<<"Enter the amount U want to deposit: t"; cin>>d_amount; cout<<endl; bal_amount=bal_amount+d_amount; cout<<"Balance: t"<<bal_amount<<endl; } }; void main() { clrscr(); members m[max]; unsigned long acc_no; int n; cout<<"The no of records U want 2 be entered: t"<<endl; cin>>n; cout<<"Enter the following Records"<<endl; for (int i=0;i<n;++i) { cout<<"Record:t"<<i+1<<endl; m[i].getdata(); } clrscr(); for (i=0; i<n; ++i) {cout<<"Record "<<i+1<<endl; m[i].putdata(); } char ch; cout<<"Do u want 2 continue for any account?"<<endl; cin>>ch; clrscr(); while(ch=='y') { cout<<"Enter ur account not"<<endl; cin>>acc_no; for(i=0; i<n; i++) { if(acc_no==m[i].accnumb) { int opt; 3|Page
  • 4. OBJECT ORIENTED PROGRAMMINGS 2010 m[i].putdata(); char ans; cout<<"Do U want 2 continue for any account-process(y/n)?t"; cin>>ans; cout<<endl; while(ans=='y') { cout<<"Enter ur option (1-check balance, 2-deposit, 3-withdraw)"<<endl; cin>>opt; cout<<endl; switch(opt) { case 1: m[i].check_balance(); break; case 2: m[i].deposit_amount(); break; case 3: m[i].withdraw(); break; deafault: cout<<"Wrong Option"<<endl; } cout<<"Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?"<<endl; cin>>ans; cout<<endl; } } } cout<<"Do U want 2 continue for any other account?"<<endl; cin>>ch; } getch(); } OUTPUT The no of records U want 2 be entered: 3 Enter the following Records Record 1 Name: Sarvesh Enter Account No: 123456 Enter the Account-type: Current Enter the balance amount: 91234567 4|Page
  • 5. OBJECT ORIENTED PROGRAMMINGS 2010 Record 2 Name: Prashant Enter Account No: 456789 Enter the Account-type: Saving Enter the balance amount: 90234567 Record 3 Name: Rajeev Enter Account No: 789012 Enter the Account-type: Current Enter the balance amount: 98765432 Clear-screen.............. Record 1 Name: Sarvesh Account No: 123456 Account-type: Current Balance amount: 91234567 Record 2 Name: Prashant Account No: 456789 Account-type: Saving Balance amount: 90234567 Record 3 Name: Rajeev Account No: 789012 Account-type: Current Balance amount: 98765432 Do u want 2 continue for any account? y Clear-screen... Enter ur account no 789012 Name: Rajeev Account No: 789012 Account-type: Current Balance amount: 98765432 Do U want 2 continue for any account-process(y/n)? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 1 Balance: 98765432 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 2 Enter the amount U want to deposit: 67890543 Balance: 166655975 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 3 Enter the amount U want to withdraw: 4567890 U have entered the wrong amount. Amount less than balance and multiple of 100 only can be withdrawn Amount withdrawn: 0 Balance: 166655975 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 5|Page
  • 6. OBJECT ORIENTED PROGRAMMINGS 2010 3 Enter the amount U want to withdraw: 4567800 Amount withdrawn: 4567800 Balance: 162088175 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? n Do U want 2 continue for any other account? n Q 2) Write an operator overloading program to write S3+=S2. 6|Page
  • 7. OBJECT ORIENTED PROGRAMMINGS 2010 #include<iostream.h> #include<conio.h> class numb { private: int i; public: numb() { i=10; } void operator++() { i=i+1; cout<<i<<endl; } }; void main() { numb n; clrscr(); int j; cout<<"How many times u want to increment the value?t"; cin>>j; for(int m=0;m<j;++m) {n.operator++(); } getch(); } OUTPUT 7|Page
  • 8. OBJECT ORIENTED PROGRAMMINGS 2010 How many times u want to increment the value? 8 11 12 13 14 15 16 17 18 // overloading prefix ++ incrementer operator for obtaining Fibonacci series #include<iostream.h> #include<conio.h> class fibonacci { private: unsigned long int f0, f1, fib; public: fibonacci(); //constructor void operator++(); void display(); }; fibonacci::fibonacci() { f0=0; f1=1; fib=f0+f1; } void fibonacci::display() { cout<<fib<<"t"; } void fibonacci::operator++() {f0=f1; f1=fib; fib=f0+f1; } 8|Page
  • 9. OBJECT ORIENTED PROGRAMMINGS 2010 void main() { clrscr(); fibonacci obj; int n; cout<<"How many fibonacci numbers are to be displayed? n"; cin>>n; for(int i=0; i<=n-1;++i) { obj.display(); ++obj; } getch(); } OUTPUT How many fibonacci numbers are to be displayed? 10 1 2 3 5 8 13 21 34 55 89 Q 3) Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class. 9|Page
  • 10. OBJECT ORIENTED PROGRAMMINGS 2010 //overloading of comparison operators #include<iostream.h> #include<conio.h> class sample { private: int value; public: sample(); sample( int one); void display(); int operator > (sample obj); }; sample::sample() { value = 0; } sample::sample( int one) 10 | P a g e
  • 11. OBJECT ORIENTED PROGRAMMINGS 2010 { value = one; } void sample::display() { cout<<"value "<<value<<endl; } int sample::operator > (sample obja) { return (value > obja.value); } void main() { clrscr(); sample obja(20); sample objb(100); cout<<(obja>objb)<<endl; cout<<(objb>obja)<<endl; getch(); } OUTPUT 0 1 11 | P a g e
  • 12. OBJECT ORIENTED PROGRAMMINGS 2010 Q 4) WAP using Single and Multiple Inheritance. //single inheritance using array of objects #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<iomanip.h> const int max=100; class basic_info { private: char name[30]; long int rollno; char sex; public: void getdata(); void display(); }; //end of class declaration class physical_fit:public basic_info { private: float height,weight; public: void getdata(); void display(); }; void basic_info::getdata() 12 | P a g e
  • 13. OBJECT ORIENTED PROGRAMMINGS 2010 { cout<<"ENTER A NAME ? n"; cin>>name; cout<<"ROLL No. ? n"; cin>>rollno; cout<<"SEX ? n"; cin>>sex; } void basic_info::display() { cout<<name<<" "; cout<<rollno<<" "; cout<<sex<<" "; } void physical_fit::getdata() { basic_info::getdata(); cout<<"HEIGHT ? n"; cin>>height; cout<<"WEIGHT ? n"; cin>>weight; } void physical_fit::display() { basic_info::display(); cout<<setprecision(2); cout<<height<<" "; cout<<weight<<" "; } void main() { clrscr(); physical_fit a[max]; int i,n; cout<<"HOW MANY STUDENTS ? n"; cin>>n; cout<<"ENTER THE FOLLOWING INFORMATION n"; for(i=0;i<=n-1;++i) { cout<<"RECORD : "<<i+1<<endl; a[i].getdata(); } cout<<endl; cout<<"_________________________________________________ n"; cout<<"NAME ROLLNO SEX HEIGHT WEIGHT n"; cout<<"_________________________________________________ n"; for(i=0;i<=n-1;++i) 13 | P a g e
  • 14. OBJECT ORIENTED PROGRAMMINGS 2010 { a[i].display(); cout<<endl; } cout<<endl; cout<<"_________________________________________________ n"; getch(); } OUTPUT HOW MANY STUDENTS? 3 ENTER THE FOLLOWING INFORMATION RECORD: 1 ENTER A NAME? Sarvesh ROLL No. ? 13 SEX? M HEIGHT? 174 WEIGHT? 59 RECORD : 2 ENTER A NAME? Prashant ROLL No. ? 19 SEX ? M HEIGHT? 166 WEIGHT? 63 RECORD : 3 ENTER A NAME ? Rajeev ROLL No. ? 23 SEX ? M HEIGHT? 14 | P a g e
  • 15. OBJECT ORIENTED PROGRAMMINGS 2010 164 WEIGHT? 53 _________________________________________________ NAME ROLLNO SEX HEIGHT WEIGHT _________________________________________________ Sarvesh 13 M 174 59 Prashant 19 M 166 63 Rajeev 23 M 164 53 _________________________________________________ #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> class baseA { public: int a; }; class baseB { public: int a; }; 15 | P a g e
  • 16. OBJECT ORIENTED PROGRAMMINGS 2010 class baseC { public: int a; }; class derivedD: public baseA,public baseB, public baseC { public: int a; }; void main() { clrscr(); derivedD objd; objd.a=10; //local to the derived class cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a; cout<<endl; cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a; cout<<endl; cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a; cout<<endl; cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a; cout<<endl; cout<<endl; getch(); } #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> class baseA { public: int a; }; class baseB 16 | P a g e
  • 17. OBJECT ORIENTED PROGRAMMINGS 2010 { public: int a; }; class baseC { public: int a; }; class derivedD: public baseA,public baseB, public baseC { public: int a; }; void main() { clrscr(); derivedD objd; objd.a=10; objd.baseA::a=20; objd.baseB::a=30; objd.baseC::a=40; cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a; cout<<endl; cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a; cout<<endl; cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a; cout<<endl; cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a; cout<<endl; cout<<endl; getch(); } OUTPUT VALUE OF a IN THE DERIVED CLASS = 10 VALUE OF a IN THE baseA = 20 VALUE OF a IN THE baseB = 30 17 | P a g e
  • 18. OBJECT ORIENTED PROGRAMMINGS 2010 VALUE OF a IN THE baseC = 40 18 | P a g e