//Program file: chbook.cpp
//This program updates a checkbook
#include <iostream.h>
#include <iomanip.h>
int main ()
{
double starting_balance, ending_balance, trans_amount;
char trans_type;
//module for getting the data
cout << "Enter the starting balance and press <Enter>: ";
cin >> starting_balance;
cout << "Enter the transaction type (D) deposit or (W) withdrawl ";
cout << "and press <Enter>: ";
cin >> trans_type;
cout << "Enter the transaction amount and press <Enter>: ";
cin >> trans_amount;
//module for performing computations
if(trans_type == 'D')
ending_balance = starting_balance + trans_amount;
else
ending_balance = starting_balance - trans_amount;
//module for displaying results
cout << setiosflags (ios::fixed | ios::showpoint | ios:: right)
<< setprecision(2);
cout << endl;
cout << "Starting balance $" << setw(8)
<< starting_balance << endl;
cout << "Transaction $" << setw(8)
<< trans_amount << setw(2) << trans_type << endl;
cout << setw(30) << "-------" << endl;
cout << "Ending balance $" << setw(8)
<< ending_balance << endl;
return 0;
}
Is anything wrong with this code? Is there something I'm missing? Is there a different way to run these programs?
Moose

New Topic/Question
Reply




MultiQuote






|