hi guys how are you,, I have a problem in my program if anybody can fix it for me please, i shall be very thankful,, Please guys i request you to please give me the solution
hi guys how are you,, I have a problem in my program if anybody can fix it for me please, i shall be very thankful,,
For character literals i used STRLEN() function and then to convert it into to string through ATOI() function is used,,,, when I run the program so it shows me that STRLEN() and ATOI() are not declared in this scope...
but then I putted header files include<string.h> and include<stdlib.h>
When I again run my program, its a banking program, it ask, Do you want to do some banking, when I enter yes so after yes it stops and doesn,t proceed further, dont know why, is there any problem with for loop or while loop or header files which i place after this, Please any body check it out and run it.. and fix it for me....
Thank you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include <iostream>
#include <string.h>
#include<stdlib.h>
using namespace std;
void MakeDeposit(); //functions prototype??//
void MakeWithdrawal();
void GetBalance();
float balance = 0;
float newBalance = 0;
float adjustment = 0;
int main()
{
char response[256];
string moreBankingBusiness;
cout << "Do you want to do some banking? ";
cin >> moreBankingBusiness;
for (int i = 0; i < moreBankingBusiness.length(); i++) {
moreBankingBusiness[i] = toupper (moreBankingBusiness[i]);
}
while (moreBankingBusiness == "YES") {
cout << "What would you like to do? " <<"(1=Deposit, 2=Withdraw, 3=Get Balance): " <<endl;
cin.getline(response,256);
if (strlen(response) == 0) {
cout << "You must make a selection";
return 1;
}
else
if (atoi(response) < 1 |
atoi(response) > 3) {
cout << response <<
" - is not a valid banking function";
return 1;
}
if (atoi(response) == 1) {
MakeDeposit();
}
if (atoi(response) == 2) {
MakeWithdrawal();
}
if (atoi(response) == 3) {
GetBalance();
}
balance = newBalance;
cout << "Do you have more banking business? ";
cin >> moreBankingBusiness;
for (int i = 0;
i < moreBankingBusiness.length(); i++) {
moreBankingBusiness[i] =
toupper (moreBankingBusiness[i]);
}
} // end of while
cout << endl << endl << "Thanks for banking with us!";
return 0;
}
void MakeDeposit()
{
cout << "Enter the Deposit Amount: ";
cin >> adjustment;
newBalance = balance + adjustment;
cout << endl << endl <<
"*** SMILEY NATIONAL BANK ***" << endl << endl;
cout << "Old Balance is: " << balance << endl;
cout << "Adjustment is: +" << adjustment << endl;
cout << "New Balance is: " << newBalance
<< endl <<endl;
}
void MakeWithdrawal()
{
cout << "Enter the Withdrawal Amount: ";
cin >> adjustment;
newBalance = balance - adjustment;
cout << endl << endl <<
"*** SMILEY NATIONAL BANK ***" << endl << endl;
cout << "Old Balance is: " << balance << endl;
cout << "Adjustment is: -" << adjustment << endl;
cout << "New Balance is: " << newBalance
<< endl <<endl;
}
void GetBalance()
{
cout << endl << endl <<
"*** SMILEY NATIONAL BANK ***" << endl << endl;
cout << "Your current Balance is: " <<
newBalance << endl <<endl;
}
|