I can't seem to understand why this program wont allow me to enter a withdrawal. It only allows me to make a deposit.Code:#include <iostream> #include <cstring> using namespace std; int main(){ int money; int withdrawal; int balance; int deposit; char string[9]; money=100; cout<<"Enter the type of transaction you would like to make (deposit or withdrawal)"; cin.getline(string,9,'\n'); if(strcmp ( string, "withdrawal") == 0){ cout<<"Enter the amount of money you would like to withdraw: "; cin>>withdrawal; balance=money-withdrawal; cout<<"Your balance is "<<balance<<"\n"; system("pause"); } else if(strcmp ( string, "deposit") == 0){ cout<<"Enter the amount of money you would like to deposit: "; cin>>deposit; balance=money+deposit; cout<<"Your balance is "<<balance<<"\n"; system("pause"); } }
I'd appreciate your help,
-pat3lbr0s2014-



LinkBack URL
About LinkBacks


