diff --git a/.gitignore/.gitignore b/.gitignore similarity index 62% rename from .gitignore/.gitignore rename to .gitignore index 9fb6852..e926b21 100644 --- a/.gitignore/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .exe -.o +.o \ No newline at end of file diff --git a/Exercise_8/8.1_bank_account/main.cpp b/Exercise_8/8.1_bank_account/main.cpp new file mode 100644 index 0000000..b9ff9c5 --- /dev/null +++ b/Exercise_8/8.1_bank_account/main.cpp @@ -0,0 +1,129 @@ +#include +#include +#include +using namespace std; + +/* + QUESTION +*/ + +class Account +{ + string name ; + string acc_type ; + int acc_no ; + + public: + int bal ; + + void get_cust_info() + { + cout <<"Enter your name :" << endl; + cin >>name; + cout <<"Enter account no :" ; + cin >>acc_no; + cout <<"\n Enter account type :" ; + cin >>acc_type; + cout<<"\n Enter balance :"; + cin >>bal; + } +}; + +class curr_acc : public Account +{ + int amount; + int min_bal ; + + void initialize_min_bal() + { + min_bal = 500; + } + void get() + { + cout << ""; + cout <<"Enter amount that you want to pass in cheque" << endl; + cin >> amount; + + if(bal <= min_bal) + { + cout <<"Penalty will be charged of rs.100 because of insufficient balance !" <>prin_amount; + cout <<"\nEnter the annual interest rate (decimal)"<>int_rate; + cout <<"\nEnter the number of years the money is invested or borrowed for :" <>time; + cout <<"\nEnter the number of times that interest is compounded per year :" <>n; + } + + void calculate_interest() + { + interest = pow((1 +(int_rate/n)) , (n*time)); + cout<<"\n Interest is :" << interest; + cout<<"The total balance is :" << interest+bal; + } + +}; + +int main() +{ + Account acc ; + sav_acc sav; + curr_acc cur; + int depo , no; + + cout<<"Enter details :"<> depo; + acc.bal += depo; + + case 2: + cout<< "Your current balance is :" << acc.bal; + + case 3: + //cout<< "Computed interest is :" << sav.calculate_interest(); + cout<< "Computed interest is :"< +#include + +using namespace std; + +class Staff +{ + int code ; + string name ; + + public: + void get_staff_info() + { + cout <<"\nEnter your code and name :" <> code >> name; + cout << "Code :" << code << "\tName :" << name<> subject >> publication ; + cout <<"Subject :" << subject << "\tPublication :" << publication <>speed; + cout <<"Your speed is :" <>daily_wages; + cout <<"\nYou are casual typist and your daily wages are :" << daily_wages<>off.grade; + off.get_off_info(); + + cout<<"\nEnter which type of typist you are ?"<>ch; + if(ch == 'r') + Regular reg; + else if(ch == 'c') + cas.casual_typist_info(); + + return 0; +} diff --git a/Exercise_8/8.4_edu_class/main.cpp b/Exercise_8/8.4_edu_class/main.cpp new file mode 100644 index 0000000..974b65d --- /dev/null +++ b/Exercise_8/8.4_edu_class/main.cpp @@ -0,0 +1,134 @@ +#include +#include + +using namespace std; + +class Staff +{ + int code ; + string name ; + + public: + void get_staff_info() + { + cout <<"\nEnter your code and name :" <> code >> name; + cout << "Code :" << code << "\tName :" << name<> subject >> publication ; + cout <<"Subject :" << subject << "\tPublication :" << publication <>speed; + cout <<"Your speed is :" <>daily_wages; + cout <<"\nYou are casual typist and your daily wages are :" << daily_wages<>chr; + + if(chr == 'g') + cout << "You have general education."; + else if(chr == 'p') + cout<<"You have proffesional education."; + } +}; +int main() +{ + Staff stf; + Teacher tch; + Typist typ; + Casual cas; + Education edu; + + cout<<"Enter details as required :" << endl; + + stf.get_staff_info(); + + tch.teacher_info(); + + typ.get_speed(); + + cout<<"\nEnter which type of officer you are :"<>off.grade; + off.get_off_info(); + + cout<<"\nEnter which type of typist you are ?"<>ch; + if(ch == 'r') + Regular reg; + else if(ch == 'c') + cas.casual_typist_info(); + + edu.get_info_edu(); + + return 0; +} diff --git a/Exercise_8/8.5_modified_edu_class/main.cpp b/Exercise_8/8.5_modified_edu_class/main.cpp new file mode 100644 index 0000000..a9f4dcd --- /dev/null +++ b/Exercise_8/8.5_modified_edu_class/main.cpp @@ -0,0 +1,60 @@ +/* Exercise_8_8.5*/ +#include +#include + +using namespace std; + +class Person +{ + public: //as data memebers are protected , it can be used by their subclasses + int personCode ; + string PersonName; +}; + +class Account : Person +{ + protected: //as data memebers are protected , it can be used by their subclasses + int pay; +}; + +class Admin : Person +{ + protected : //as data memebers are protected , it can be used by their subclasses + int exp; +}; + +class Master : Account , Admin +{ + public: + + void disp_person_info() //displays person's information + { + cout <<"Enter name and code :"<> personCode>> personName; + cout<<"Code:"<>pay; + cout<<"Your paid amount is :" << pay<> exp; + cout<<"You have " << exp << "year expereince" << endl; + } +}; +int main() +{ + Master mas; + + mas.disp_person_info(); + mas.disp_exp(); + mas.get_amount(); + + return 0; +} diff --git a/Exercise_8/8.6_use_container_class/8.6_use_container_class.cpp b/Exercise_8/8.6_use_container_class/8.6_use_container_class.cpp new file mode 100644 index 0000000..6863d4a --- /dev/null +++ b/Exercise_8/8.6_use_container_class/8.6_use_container_class.cpp @@ -0,0 +1,134 @@ +/*using container class re-writing exercise 8.3*/ +#include +#include + +using namespace std; + +class Staff +{ + int code ; + string name ; + + public: + void get_staff_info() + { + cout <<"\nEnter your code and name :" <> code >> name; + cout << "Code :" << code << "\tName :" << name<> subject >> publication ; + cout <<"Subject :" << subject << "\tPublication :" << publication <>speed; + cout <<"Your speed is :" <>grade; + cout<<"\nYou are " << grade << " grade officer" <>daily_wages; + cout <<"\nYou are casual typist and your daily wages are :" << daily_wages<>ch; + if(ch == 'r' || 'R') + Regular reg; + else if(ch == 'c' || 'C') + cas.casual_typist_info(); + + + //cout<<"\nEnter which type of officer you are :"<>off.grade; + + + /*cout<<"\nEnter which type of typist you are ?"<>ch; + if(ch == 'r') + Regular reg; + else if(ch == 'c') + cas.casual_typist_info(); +*/ + return 0; +}