Answer to Question #270051 in C++ for Meisum

Question #270051

How can you impliment debit and credit statements to get profit and loss result accordingly using if else and goto statements in C++?. My project is account management with profit and loss, Thanks.


1
Expert's answer
2021-11-23T05:19:05-0500
#include<iostream>
using namespace std;
class Account{
	public:
	void credit(){
	  float amount;
	  int balance;
      void display();
      cout<<"Enter amount:";
      cin>>amount;
      balance=balance+amount;
      display();
	}
	void debit(){
	  float amount;
	  int balance;
      void display();
      cout<<"Enter amount:";
      cin>>amount;
      if(balance<amount)
         cout<<"Insufficient balance\n";
      else
         balance=balance-amount;
      display();
      
	}
	
};
int main()
{
	Account A;
	int option;
	cout<<"Enter an option: ";
	cin>>option;
	if(option==1)
	goto credit;
	else
	goto debit;
	credit:
		cout<<"Crediting";
		A.credit();
	debit:
		cout<<"Debiting";
		A.debit();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS