Thread: Iteration of loop

  1. #1
    Registered User
    Join Date
    May 2009

    Iteration of loop

    Hello All,

    Here is the programm simulating the ATM.

    I want the little help in how to repeat the conditions in loop, because as I change the conditions, program doesn't perform any calculation.

    Kindly if anybody can help me in this regard.

    class BankTransaction
    	int iBalance,NewBalance,Adjustment,AnnualInterestRate,Interest;
    	void Deposit();
    	void Withdrawl();
    	void Balance();
    	void Display();
    	void InterestRate();
    	void AnnualInterest();
     void BankTransaction :: Deposit ()
    		cout<<"\n Enter the amount to deposit:";
    		iBalance = iBalance + NewBalance;
     void BankTransaction :: Withdrawl()
    		int amount = 0;
    		cout<<"Enter amount to be withdraw:\n";
    		if(amount >iBalance)
    			cout<<"Not enough balance to be withdrawn.\n";;
    			cout<<"Maximum money can be withdrawn: "<<iBalance<<"\n";
    		  iBalance = iBalance - amount;
     void BankTransaction :: Balance()
    	       cout<<"Current Balnce: " <<iBalance;
    void BankTransaction:: InterestRate()
    		cout<<"\n Enter the interest rate: \n";
    void BankTransaction:: AnnualInterest ()
    		cout<<"\n Enter the interest rate: \n";
    		iBalance = iBalance -(AnnualInterestRate / 100);
    		  cout<<"Current Balance: " << iBalance;
    void main()
    			BankTransaction  a; //creating array of objects
    			int input = 0;
    				cout<<"\n Enter the value to perform : \n";
    				cout<<"\n 1: Deposit : \n";
    				cout<<"\n 2: Withdraw : \n";
    				cout<<"\n 3: Get Balance : \n";
    				cout<<"\n 4: Set annual interest rate  : \n";
    				cout<<"\n 5: Calculate interest  : \n";
    				cin>>input ;
    				if(input == 1)
    			       else if(input == 2)
    			       else if(input == 3)
    			       else if(input == 4)
    			       else if(input == 5)
    			       //	 a.Display();
    			}while(input == 0);

  2. #2
    The larch
    Join Date
    May 2006
    Perhaps you meant to loop

    while(input != 0);
    You'll see you have other problems, like having uninitialized member variables.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User n3cr0_l0rd's Avatar
    Join Date
    Feb 2009
    The loop will continue if the input is 0. But that would be useless because if the input is 0, you will just keep on looping without doing anything. If you meant to loop every time the input is not 0, do as anon said. Again that will lead you to never-ending loop unless you input 0.

    You have used clrscr() at the beginning of the loop so don't expect to see the results displayed by
    as it will erase it.

    There's a big chance i didnt get u.. :d

    something that i have learned so far. Maybe you would like to know too. Don't use void main, instead use int main().
    The main function is required to yield an integer as its result, the purpose of which is to tell the
    implementation whether the program ran successfully. A zero value indicates success; any
    other value means there was a problem.

    conio.h is not standard header file for C++, ditch it; obviously getch() too goes with it.
    I had crush on her, before that crush could CRUSH me, i CRUSHED that crush !!! Fun time over, Lets find a way to not to blow off the whole leg !

    __________________________________________________ __________________________________________________ _______________

    In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg.
    - Bjarne Stroustrup

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual Studio Express / Windows SDK?
    By cyberfish in forum C++ Programming
    Replies: 23
    Last Post: 01-22-2009, 02:13 AM
  2. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-31-2006, 12:59 AM
  3. kernel iteration through for loop
    By sononix in forum C++ Programming
    Replies: 4
    Last Post: 08-11-2004, 06:16 AM
  4. Loop iteration v's vectors
    By sononix in forum C++ Programming
    Replies: 2
    Last Post: 08-04-2004, 10:25 AM
  5. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM