Categories
Personal Reflections

A BIG Sorry To All My Subscribers!

Dear Subscribers of my feed and email updates,

You may have noticed that for the past few days, you’ve been receiving an UNNATURAL amount of updates from my blahg, especially on older articles. I request you to bear with me about this, because I’m transitioning some files and other embedded objects to better servers. Overall, your user experience with files will be much better, I promise. For example, the podcasts are now streamed by default. Also, you don’t need to go to a landing page any longer for downloads, all downloads are now start directly. There’s no need to use open in new tab / page any longer, you can safely start a download without losing the page you’re currently viewing.

Thanks for your cooperation, and I promise that this phase will be over soon.

– GQ

Categories
Uncategorised

Classes – Accounts

/* Copyright © 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html /

/ Classes – Program to manage accounts /

#include <iostream.h>
#include <conio.h>
#include <stdio.h>

int i, n, amt;
char tran;

class account
{
int num;
char name[50];
float bal;
static float tot, totd, totw;
public:
void accept()
{
cout<<endl<<“Enter data for account “<<i + 1<<endl
<<“Enter account number : “;
cin>>num;
cout<<“Enter account name : “;
gets(name);
cout<<“Enter balance amount : “;
cin>>bal;
}
void disp(int no)
{
if (no == num)
{
cout<<endl<<“Displaying data for requested “<<“account”
<<endl<<“Accountnumber : “<<num<<endl
<<“Account name : “<<name<<endl
<<“Account balance : “<<bal;
}
}
void trans(int no, char t, float a)
{
if (no == num)
{
if (t == ‘d’)
{
bal += a;
totd += a;
}
else if (t == ‘w’)
{
bal -= a;
totw += a;
}
}
tot = totd – totw;
}
static void total()
{
cout<<endl<<“Total deposits by all account holders : “<<totd<<endl
<<“Total withdrawals made by all account holders : “<<totw<<endl
<<“Total of all transactions done by all account holders : “<<tot;
}
} acc[5];

float account::tot = 0.0;
float account::totd = 0.0;
float account::totw = 0.0;

void main()
{clrscr();
int ch;
char choice;
cout<<endl<<“Account Management Program\n \n”
<<“Enter initial details for all accounts”<<endl;
for (i = 0; i < 5; i++)
acc[i].accept();
do
{
cout<<endl<<“Program Menu”<<endl
<<“1. Display data for particular account”<<endl
<<“2. Carry out transaction”<<endl
<<“3. Display total withdrawal and total deposits”<<endl
<<“Enter your choice : “;
cin>>ch;
if
(ch == 1)
{
cout<<endl<<“Enter account number for required account : “;
cin>>n;
for (int i = 0; i < 10; i++)
acc[i].disp(n);
}
else if (ch == 2)
{
cout<<endl<<“Enter account number associated with transaction : “;
cin>>n;
cout<<“Enter type of transaction – d for deposit and w for withdrawal : “;
cin>>tran;
cout<<“Enter transaction amount : “;
cin>>amt;
for (i = 0; i < 5; i++)
acc[i].trans(n, tran, amt);
cout<<“Account balance for account number “<<n
<<” has been updated”;
}
else if (ch == 3)
{
acc[0].total();
}

else cout<<endl<<“You entered an incorrect choice”;
cout<<“\n \nDo you wish to continue – y / n : “;
cin>>choice;
} while (choice == ‘y’ || choice == ‘Y’);
cout<<endl;
getch();
}

/ Output */

Account Management Program

Enter initial details for all accounts

Enter data for account 1
Enter account number : 42
Enter account name : Ankur Banerjee
Enter balance amount : 875

Program Menu
1. Display data for particular account
2. Carry out transaction
3. Display total withdrawal and total deposits
Enter your choice : 1

Enter account number for required account : 42

Displaying data for requested account
Account number : 42
Account name : Ankur Banerjee
Account balance : 875

Program Menu
1. Display data for particular account
2. Carry out transaction
3. Display total withdrawal and total deposits
Enter your choice : 2

Enter account number associated with transaction : 42
Enter type of transaction – d for deposit and w for withdrawal : d
Enter transaction amount : 420

Account balance for account number 42 has been updated

Program Menu
1. Display data for particular account
2. Carry out transaction
3. Display total withdrawal and total deposits
Enter your choice : 3

Total deposits by all account holders : 420
Total withdrawals made by all account holders : 0
Total of all transactions done by account holders : 420