Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program with function which uses a static variable to keep track of the

ID: 3909212 • Letter: W

Question

Write a program with function which uses a static variable to keep track of the current balance of a bank account. Do not allow an overdraft! A typical run would be: CWindowslsystem321cmd.exe nter anount of transaction, positive for deposit, negative For withdraual 145.00 urrent balance145.00 Do you have more transactions? or N nter anount of transaction positive fordeposit, negative for withdraual 5.00 urrent balance170.00 Do you have more transactions? Y or N nter anount of transaction, positive For deposit. negative for withdrawal 30.00 urrent balance140.00 o you have more transactions? Y or N nter anount of transaction, positive for deposit, negative for withdrawal 150.8 Inpernissible vithdrawal. insufficient funds nter anount of transaction, positive For deposit, negative for withdraual 15.00 urrent balance 125.00 Do you have nore transactions? Y or N Final balance 125.00 ress any key to continue nter anount of transaction,positive for deposit. negative for withdraual 145.00 urrent balance145.00 Do you have nore transactions? Y or N nter anount of transaction, positive for deposit. negative for withdraual 5.00 urrent balance170.00 Do you have nore transactions? or N nter anount of transaction, positive for deposit. negative for withdraval 30.00 urrent balance140.08 Do you have nore transactions? Y or N Enter anount of transaction positive for deposit, negative for withdraval 150.80 Inpernissible withdrawal. insufficient funds nter anount of transaction. positive for deposit, negative for withdraual 15.00 urrent balance125.00 Do you have nore transactions? or N Final balance 125.00 Press any key to continue

Explanation / Answer

THE CODE FOR ABOVE PROBLEM IS:

#include<iostream>
using namespace std;
class balance
{


public :

void transaction()
{
   static float val;
static float bal;
   cout<<"enter the amount for the transaction , positive for deposit and negative for withdrawl ";
   cin>>val;
   bal=bal+val;
   cout<<"Current balanace = "<<bal<<" ";  

}

};

int main()
{
   balance b;
   char ch='Y';
   while(ch=='Y')
   {
       b.transaction();
      
       cout<<"Do you havr anymore transactions Y or N ?";
       cin>>ch;
   }
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote