### running totals... ledger need some help

I am trying to make a ledger of some sort. The ledger will prompt the user for a beginning balance and then three transactions following that using the letters "D" and "W" for deposit and withdraw respectively.

The input should look like:

Please enter the first transaction: D 1000.50
Please enter the second transaction: W 400.00
Please enter the third transaction: D 1505.50

Then I need to figure out how to calculate these running totals but that is where I am completely stumped. How do I go about do this? I also don't understand how I will make the program know that D will make an addition and W will subract. Here is my code so far:

 ``1234567891011121314151617181920212223242526`` ``````#include using namespace std; int main() { double begin, first, second, third; cout << "Enter your beginning balance: " << endl; cin >> begin; cout << "Use the letter D for deposit or W for withdrawal" << endl; cout << "Enter your first transaction: " << endl; cin >> first; cout << "Enter your second transaction: " << endl; cin >> second; cout << "Enter your first transaction: " << endl; cin >> third; system("PAUSE"); return 0; }``````
I left some for you to do.

 ``1234567891011121314151617181920212223242526272829`` ``````#include using namespace std; char TransType; double NewBalance=0; int main() { double begin, first, second, third; cout << "Enter your beginning balance: " << endl; cin >> begin; NewBalance=begin; cout << "Use the letter D for deposit or W for withdrawal" << endl; cout << "Enter your first transaction: " << endl; cin >> TransType >> first; if (TransType=='W') {NewBalance=NewBalance-first;} else if (TransType=='D') {NewBalance=NewBalance+first;} cout << "Starting Balance: \t" << begin << endl; cout << "Transaction Summary: \t" << NewBalance-begin << endl; cout << "Current Balance: \t" << NewBalance << endl; return 0; }``````

Last edited on
Topic archived. No new replies allowed.