Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added coded in CPP Programs #469

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
177 changes: 177 additions & 0 deletions 30. CPP Programs/Bankdetail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#include<iostream>
#include<string>
using namespace std;
class bankdetail
{
private:
string name;
string address;
int accountno;
float balance;
public:
void inputdata()
{
cout<<"enter account holders name = "<<endl;
getline(cin,name);
cout<<"enter holders address = "<<endl;
getline(cin,address);
cout<<"enter account number = "<<endl;
cin>>accountno;
cout<<"enter amount in holders account = "<<endl;
cin>>balance;
cin.clear();
cin.sync();
}
void showdata()
{
cout<<"account holders name = "<<name<<endl;
cout<<"account number = "<<accountno<<endl;
cout<<"holders address = "<<address<<endl;
cout<<"amount in holders account = "<<balance<<endl;
}
void deposit()
{
int add_amount;
cout<<" amount you want to deposit in your account = "<<endl;
cin>>add_amount;
balance=balance+add_amount;
cout<<"new deposirt money = "<<balance<<endl;
}
void withdrawl()
{
int withdrawl_amount;
cout<<"enter the amount you want to withdrawl = "<<endl;
cin>>withdrawl_amount;
balance=balance-withdrawl_amount;
cout<<"amount after withdrawing money = "<<balance<<endl;
}
void address_change()
{
string new_address;
cout<<"new address = "<<endl;
cin>>new_address;
address=new_address;
}

int search(int a)
{
if(accountno==a)
{
showdata();
}
return 0 ;
}
};

int main()
{
bankdetail data[2];
int ch,temp=0,a;
char ch2;
for(int i=0;i<5;i++)
{
data[i].inputdata();
}
do
{
cout<<"1-show all detail"<<endl;
cout<<"2-search by acc no"<<endl;
cout<<"3-deposit "<<endl;
cout<<"4-withdrawl your amount"<<endl;
cout<<"5-change address your address"<<endl;
cout<<"6-exit"<<endl;
cout<<"pleease enter your choice = "<<endl;
cin>>ch;
switch(ch)
{
case 1:

for(int i=0;i<2;i++)
{
data[i].showdata();
}
break;
case 2:

cin>>a;
for(int i=0;i<2;i++)
{
temp=data[i].search(a);
if(temp)
{
data[i].showdata();
break;
}
if(!temp)
{
cout<<"no detail found";
}
}
break;

case 3:
cin>>a;
for(int i=0;i<2;i++)
{
temp=data[i].search(a);
if(temp)
{
data[i].deposit();
data[i].showdata();
break;
}
if(!temp)
{
cout<<"no detail found";
}
}
break;

case 4:
cin>>a;
for(int i=0;i<2;i++)
{
temp=data[i].search(a);
if(temp)
{
data[i].withdrawl();
data[i].showdata();
break;
}
if(!temp)
{
cout<<"no detail found";
}
}
break;

case 5:
cout<<"enter the acc no. whose data you want to change = ";
cin>>a;
for(int i=0;i<2;i++)
{
temp = data[i].search(a);
if(temp)
{
data[i].address_change();
data[i].showdata();
break;
}
if(!temp)
cout<<"no detail found";
}
break;
case 6:
cout<<"thank you"<<endl;
break;
default:
{
cout<<""<<endl;
}

}
cout<<"do you want to continue (y/n)"<<endl;
cin>>ch2;
}while(ch2=='Y'||ch2=='y');
return 0;
}
35 changes: 35 additions & 0 deletions 30. CPP Programs/Employee.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<iostream>
using namespace std;
class employee
{
private: int Pan,Taxincome;
char Name[20];
float Tax;
public: void inputinfo()
{
cin>>Pan>>Name>>Taxincome;
}
void Taxcalc()
{
if(Taxincome<=250000)
Tax=0;
else if(Taxincome>250000 && Taxincome<=300000)
Tax=(Taxincome-2500000)*0.1;
else if(Taxincome>300000 && Taxincome<=400000)
Tax=5000+((Taxincome-300000)*0.2);
else if(Taxincome>400000)
Tax=25000+((Taxincome-400000)*0.3);
}
void Displayinfo()
{
cout<<Name<<"\n"<<Pan<<"\n"<<Taxincome<<"\n"<<Tax;
}
};
int main()
{
employee ob;
ob.inputinfo();
ob.Taxcalc();
ob.Displayinfo();
return 0;
}
60 changes: 60 additions & 0 deletions 30. CPP Programs/Inheritance 2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include<iostream>
using namespace std;
class Apples
{
protected:
int a;
public:
void c_apples()
{
cout<<"Enter number of apples"<<endl;
cin>>a;
}
void display_c_apples()
{
cout<<"The number of apples are: "<<a<<endl;
}

};
class Mangoes
{
protected:
int m;
public:
void c_mangoes()
{
cout<<"Enter number of mangoes: "<<endl;
cin>>m;
}
void display_c_mangoes()
{
cout<<"The number of mangoes are: "<<m<<endl;
}
};
class Fruit:public Apples,public Mangoes
{
private:
int t,n;
public:
void total_fruits()
{
cout<<"Enter the number of fruits other than apples and mangoes: "<<endl;
cin>>n;
t=n+a+m;
}
void display_t_fruits()
{
cout<<"The total number of fruits are: "<<t<<endl;
}
};
int main()
{
Fruit ob;
ob.c_apples();
ob.c_mangoes();
ob.total_fruits();
ob.display_c_apples();
ob.display_c_mangoes();
ob.display_t_fruits();
return 0;
}
48 changes: 48 additions & 0 deletions 30. CPP Programs/Inheritance 3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<iostream>
using namespace std;
class shape
{
protected:
float width,height;
public:
shape()
{
cout<<"Enter the value of width: "<<endl;
cin>>width;
cout<<"Enter the value of height: "<<endl;
cin>>height;
}
};
class rectangle: public shape
{
private:
float ar;
public:
void area_rec()
{
ar = height * width;
cout<<"The area of rectangle is: "<<ar<<endl;
}
};
class triangle: public shape
{
private:
float ar;
public:
void area_tri()
{
ar = 0.5 * height * width;
cout<<"The area of triangle is: "<<ar<<endl;
}

};
int main()
{
cout<<"FOR TRIANGLE"<<endl;
triangle obj;
obj.area_tri();
cout<<"FOR RECTANGLE"<<endl;
rectangle ob;
ob.area_rec();
return 0;
}
24 changes: 24 additions & 0 deletions 30. CPP Programs/Inheritance 4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;
class Mother
{
public:
void display()
{
cout<<"I am mother"<<endl;
}
};
class Daughter:public Mother
{
public:
void display()
{
cout<<"I am daughter"<<endl;
}
};
int main()
{
Daughter ob;
ob.display();
return 0;
}
40 changes: 40 additions & 0 deletions 30. CPP Programs/Inheritance 5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include<iostream>
using namespace std;
class Animal
{
private:
string name;
int age;
public:
void set_value()
{
cout<<"Enter name: "<<endl;
getline(cin,name);
cout<<"Enter age: "<<endl;
cin>>age;
}
void display()
{
cout<<"The age is: "<<age<<endl;
cout<<"Name is: "<<name<<endl;
if(name=="zebra"||name=="Zebra")
{
cout<<"The origin is Africa"<<endl;
cout<<"The color is black and white"<<endl;
}
else if(name=="dolphin"||name=="Dolphin")
{
cout<<"The origin is Miocene Epoch"<<endl;
cout<<"The color is whitish-grey"<<endl;
}
else
cout<<"Incorrect input";
}
};
int main()
{
Animal ob;
ob.set_value();
ob.display();
return 0;
}
Loading