Question: Here is a code for C++ Object Oriented Programming below. Plz make this much simpler and easy to understand because I am a beginner. Also
Here is a code for C++ Object Oriented Programming below. Plz make this much simpler and easy to understand because I am a beginner. Also explain the code and write Abstract, Introduction/detail and Critical Analysis / Conclusion.
#include #include
using namespace std; class Account{ string title, acnumber, cnic, date;
double amount; public: void setTitle(string in){title = in;} void setAcNumber(string in){acnumber = in;} void setCNIC(string in){cnic = in;} void setDate(string in){date = in;} void setAmount(double in){amount = in;} string toStringS(){ return acnumber + " " + title + " " + cnic + " " + date + " " +to_string(amount); } };
class Current : public Account{ string type; float minBal; public: Current(){ type = "current"; minBal = 25000; }
string toString(){ return type + " " + toStringS() +" "; } };
class Saving : public Account{ string type; float rate; public: Saving(){ type = "saving"; rate = 9.6; }
string toString(){ return type + " " + toStringS() + " "; } };
unsigned long (string s){ return 0; }
string getAccountType(double deposit){ if(deposit >= 25000) return "current"; else return "saving"; }
int main(){ char ch; double amt; string tmp; Current cur; Saving sav; ifstream fin; ofstream fout;
cout << "Enter details of all account holders:" << endl;
fout.open("E:\\data.txt"); do{ cout << " Enter deposit amount: "; cin >> amt; tmp = getAccountType(amt); if(tmp.compare("current") == 0){ cur = Current(); cur.setAmount(amt); cout << "Enter Title: "; cin >> tmp; cur.setTitle(tmp); cout << "Enter account number: "; cin >> tmp; cur.setAcNumber(tmp); cout << "Enter CNIC: "; cin >> tmp; cur.setCNIC(tmp); cout << "Enter Date of open: "; cin >> tmp; cur.setDate(tmp); fout << cur.toString(); } else if(tmp.compare("saving") == 0){ sav = Saving(); sav.setAmount(amt); cout << "Enter Title: "; cin >> tmp; sav.setTitle(tmp); cout << "Enter account number: "; cin >> tmp; sav.setAcNumber(tmp); cout << "Enter CNIC: "; cin >> tmp; sav.setCNIC(tmp); cout << "Enter Date of open: "; cin >> tmp; sav.setDate(tmp); fout << sav.toString(); }
cout << "continue entering details ? (y/n): "; cin >> ch;
}while(ch == 'y');
fout.close();
cout << " Details of all account holders:" << endl; fin.open("E:\\data.txt"); while(fin){ tmp = ""; fin >> tmp; if(tmp.compare("current") == 0){ cout << "Current Account:" << endl; fin >> tmp; cout << "\tNumber: " << tmp << endl; fin >> tmp; cout << "\tTitle: " << tmp << endl; fin >> tmp; cout << "\tCNIC: " << tmp << endl; fin >> tmp; cout << "\tDate: " << tmp << endl; fin >> tmp; cout << "\tAmount: " << tmp << endl; } else if(tmp.compare("saving") == 0){ cout << "Saving Account: " << endl; fin >> tmp; cout << "\tNumber: " << tmp << endl; fin >> tmp; cout << "\tTitle: " << tmp << endl; fin >> tmp; cout << "\tCNIC: " << tmp << endl; fin >> tmp; cout << "\tDate: " << tmp << endl; fin >> tmp; cout << "\tAmount: " << tmp << endl; cout << "\tInterest for 3 months: " << (tmp, 10) * 9.6 / 100 * 3 << endl; } } fin.close();
return 0; }
Plz send your number I will explain the question there. Because other people will see the qs here.
send your what's app no.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
