Question

Write a simple checkbook balancing program Input will contain either the word withdraw or deposit. The next line will con

Please mad in dev c++ software

ng n görüntüle + Şuraya ekle ♡ ♡ Ara % Duzenle ve Oluştur main Binclude <stdio.h> 2 dinclude <stdlib.h> 4- int main() { 5 dou

That is example. But it is wrong

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

Let me know for any help with any other questions.

Thank You!


===========================================================================

#include<iostream>
#include<string>


using namespace std;

int main(){
  
   float balance; float amount;
   string transaction;
  
   cout<<"Enter transaction (type \"exit\" to stop): " ;
   cin >> transaction;
   while(transaction.compare("exit")!=0){
      
       if(transaction.compare("deposit")==0){
           cout<<"Enter deposit amount: "; cin >> amount;
           balance += amount;
       }
      
       else if(transaction.compare("withdraw")==0){
           cout<<"Enter withdraw amount: "; cin >> amount;
           balance -= amount;
       }
       else{
           cout<<"\nError: Invalid transaction.\n\n";
       }
       cout<<"balance: $" << balance << endl;
       cout<<"Enter transaction (type \"exit\" to stop): ";
       cin >> transaction;
   }


   return 0;
}

====================================================================

DEV Х C:\Users\User\Documents balanced.cpp - [Executing] - Dev-C++ 5.11 Eile Edit Search View Project Execute Tools Style Win

Add a comment
Know the answer?
Add Answer to:
Please mad in dev c++ software That is example. But it is wrong Write a simple...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT