i have finished writing my program, but teacher want me to write a checkbook balancing program of a user's account. It has to use getline () to read a line, which will contain either the word "withdrawal" or "deposit". After reading each pair of line, the program should compute and print new balance. I think i need to declare a variable to hold the running balance. The program must warn when the user if the withdrawal exceeds the balance.
*input should be somthing like this:

1.deposit
2.100
3.withdrawal
4.12.34
5.withdrawal
6.49.00
7.deposit
8.7.01

*OUT PUT of the program should print something like:

balance:100.00
balance:87.66
balance:38.66
balance:45.67

------------------------------------
>>BELOW IS THE PROGRAM I HAVE WRITTEN - PLS HELP!
--------------------------------------…

//************************************…
// 
// Description:A basic checkbook balancing system.

#define win
#ifdef lin
#include <iostream>
#include <ctype>
#endif /* lin */
#ifdef win
#include <iostream.h>
#include <ctype.h>
#endif /* win */
using namespace std;
void clr(unsigned int lines);
int main(void) {
char correct[20], correkt, p_m;
bool pass=true, done=false;// Boolean variables are either true or false
unsigned int i=0; // Unsigned means that it will not be negative
float prev_bal, balance=0.0, w_d=0.0;
cout << endl << "Welcome to" << endl;
cout << "C H E C K B O O K" << endl;
cout << " Version 0.8.91" << endl;
do {
cout << "Enter income $";
cin >> balance;
if(balance < 0) { pass=false; break; }
if(pass==true) {
cout << "Income ~ $" << balance << endl;
cout << "... Is this correct? > ";
cin >> correct;
correkt=toupper(correct[0]);
if(correkt=='Y' || correkt=='T') {}
else if(correkt=='N' || correkt=='F') pass=false;
else if(correkt=='X') { return 0; }
else { cout << "ERROR: Bad input."; pass=false; }
}
cout << endl;
} while(pass==false);
clr(0);
cout << "T R A N S A C T I O N S" << endl << endl;
cout << "Please input if each transaction was a" << endl;
cout << "(W)ithdraw -or- (D)eposit" << endl << endl;
cout << "At the prompt after the final withdraw or deposit, input X to quit." << endl;
cout << endl << endl;
/* We're reusing the `correct' and `pass' vars here to save memory. */
for(;;i++) {
do {
prev_bal = balance;
cout << "Transaction " << i << ": (W)ithdraw or (D)eposit? (X to quit) > ";
cin >> correct;
correkt=toupper(correct[0]);
if(correkt=='W') {
w_d=0.0;
cout << endl << endl << "How much is withdrawn? $";
cin >> w_d;
balance -= w_d;
pass=true;
p_m='-';
}
else if(correkt=='D') {
pass=true; 
w_d=0.0;
cout << endl << "How much is deposited? $";
cin >> w_d;
balance += w_d;
p_m='+';
}
else if(correkt=='X') { done=true; }
else { cout << "ERROR: Bad input."; pass=false; }
cout << endl;
} while(pass==false);
if(done==true) break;
if(pass==true) {
cout << endl << "-- prev balance -- " << prev_bal;
cout << endl << " " << p_m << w_d;
cout << endl << "------------------ ";
cout << "Your balance is $" << balance;
cout << " ------------------" << endl << endl;
}
} //end i++ loop
clr(0);
cout << endl << "------------------ ";
cout << "Your final balance is $" << balance;
cout << " ------------------" << endl << endl;
cout << endl << endl << "Checkbook by KALHU." << endl << endl;
return 0;
}
void clr(unsigned int lines) {
unsigned int i;
if(lines==0) lines=99;
for(i=0; i<=lines; i++) { cout << endl; }
}

Help with what? You need to explain whatever problem you are having.

You also need to format your code because, as posted, it's unreadable.

The program must warn when the user if the withdrawal exceeds the balance.
*input should be somthing like this:

1.deposit
2.100
3.withdrawal
4.12.34
5.withdrawal
6.49.00
7.deposit
8.7.01

*OUT PUT of the program should print something like:

balance:100.00
balance:87.66
balance:38.66
balance:45.67

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.