fork download
  1. // Lab oops, lab journal
  2. // Programmer : Vaishnavi Tomar
  3. // Editor(s) used : Code Blocks 13.12
  4. // Compiler(s) used : Code Blocks 13.12
  5.  
  6. #include<iostream>
  7. #include<string>
  8. using namespace std;
  9. class BankAccount {
  10. private:
  11. string name;
  12. int accountNumber;
  13. string accountType;
  14. float balance;
  15. float tariff;
  16. int nod;
  17. public:
  18. void Checkin(int accNo, string accName, string accType, float initialBalance, float tariffRate,
  19. int days) {
  20. accountNumber = accNo;
  21. name = accName;
  22. accountType = accType;
  23. balance = initialBalance;
  24. tariff = tariffRate;
  25. nod = days;
  26. }
  27. void deposit(float amount) {
  28. balance += amount;
  29. cout << "Amount deposited successfully. New balance: " << balance << endl;
  30. }
  31. void withdraw(float amount) {
  32. if (balance >= amount) {
  33. balance -= amount;
  34. cout << "Amount withdrawn successfully. Remaining balance: " << balance << endl;
  35. } else {
  36. cout << "Insufficient balance. Transaction failed." << endl;
  37. }
  38. }
  39. void display() const {
  40. cout << "Depositor Name: " << name << endl;
  41. cout << "Account Number: " << accountNumber << endl;
  42. cout << "Account Type: " << accountType << endl;
  43. cout << "Balance: " << balance << endl;
  44. }
  45. float calculateTotalAmount() const {
  46. if (balance > 10000) {
  47. return 1.05 * balance;
  48. } else {
  49. return balance + (nod * tariff);
  50. }
  51. }
  52. };
  53. int main() {
  54. BankAccount account;
  55. int accountNumber;
  56. string name, accountType;
  57. float initialBalance, tariffRate;
  58. int nod;
  59. cout << "Enter Account Number: ";
  60. cin >> accountNumber;
  61. cin.ignore();
  62. cout << "Enter Name of Depositor: ";
  63. getline(cin, name);
  64. cout << "Enter Account Type (Saving/Current): ";
  65. cin >> accountType;
  66. cout << "Enter Initial Balance: ";
  67. cin >> initialBalance;
  68. cout << "Enter Tariff Rate: ";
  69. cin >> tariffRate;
  70. cout << "Enter Number of Days (NOD): ";
  71. cin >> nod;
  72. account.Checkin(accountNumber, name, accountType, initialBalance, tariffRate, nod);
  73. account.deposit(5000);
  74. account.withdraw(3000);
  75. account.display();
  76. float totalAmount = account.calculateTotalAmount();
  77. cout << "Total amount considering tariff: " << totalAmount << endl;
  78. return 0;
  79. }
Success #stdin #stdout 0.01s 5284KB
stdin
 3
4
3
stdout
Enter Account Number: Enter Name of Depositor: Enter Account Type (Saving/Current): Enter Initial Balance: Enter Tariff Rate: Enter Number of Days (NOD): Amount deposited successfully. New balance: 5000
Amount withdrawn successfully. Remaining balance: 2000
Depositor Name: 4
Account Number: 3
Account Type: 3
Balance: 2000
Total amount considering tariff: 2000