/* Programmer: Bill Korn<br>
Login:A17<br>
Computer#:26<br>
Period:1<br>
Program Title:Check.CPP<br>
Date:11/3/99<br>
<br>
Purpose:This program will allow the user to enter a starting<br>
deposit. It will then process a series of deposits,withdrawals<br>
. Then it will print the # of withdrawals, deposits, transactions<br>
and the total of the withdrawals and deposits.\n";<br>
*/<br>
<br>
<br>
#include "trinity.h"<br>
<br>
void neo();<br>
void morpheus();<br>
double get_deposit();<br>
char get_choice();<br>
double get_amount();<br>
void setup();<br>
void print_results(double num_w, double num_d, double total,<br>
double total_w, double total_d, double balance,<br>
double initial);<br>
<br>
int main()<br>
{<br>
neo();<br>
morpheus();<br>
<br>
// Declaring Variables<br>
double initial, change, total_d, total_w, num_d, num_w, balance, count,total;<br>
char choice, cheryl;<br>
<br>
// Rerun Loop<br>
do<br>
{<br>
<br>
// Initializing Variables<br>
total_d = total_w = num_d = num_w = count = 0;<br>
<br>
// Get initial balance<br>
initial = get_deposit();<br>
balance = initial;<br>
<br>
// Setting up the screen<br>
setup();<br>
<br>
// Do while loop regulating transactions<br>
do<br>
{<br>
// Getting the choice<br>
choice = get_choice();<br>
<br>
// getting amount<br>
if(choice != 'Q' && choice != 'q')<br>
change = get_amount();<br>
<br>
<br>
// Switch regulating options<br>
<br>
switch (choice)<br>
{<br>
case 'D', 'd': total_d = total_d + change;<br>
num_d++;<br>
balance = balance + change;<br>
gotoxy(29, (4 + count));<br>
cout << setw(12) << change;<br>
gotoxy(48, (4 + count));<br>
cout << setw(11) << balance;<br>
count++;<br>
break;<br>
<br>
case 'W', 'w': if(change > balance)<br>
{<br>
gotoxy(1, 23);<br>
cout << " \t\tYou do not have enough. Press Enter";<br>
getch();<br>
cin.ignore();<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
break;<br>
}<br>
<br>
total_w = total_w + change;<br>
num_w++;<br>
balance = balance - change;<br>
gotoxy(9, (4 + count));<br>
cout << setw(15) << change;<br>
gotoxy(48, (4 + count));<br>
cout << setw(11) << balance;<br>
count++;<br>
break;<br>
case 'Q', 'q': break;<br>
}<br>
}<br>
while(choice != 'Q' && choice != 'q');<br>
<br>
// Calculating Total<br>
total = num_d + num_w;<br>
<br>
// Printing the final screen<br>
print_results(num_w, num_d, total, total_w, total_d, balance, initial);<br>
<br>
// Rerun Ask<br>
do<br>
{<br>
cout << "\n\n";<br>
cout << "\t\t Do you want to run this program again(y/n): ";<br>
cin >> cheryl;<br>
}<br>
while(cheryl != 'Y' && cheryl != 'y' && cheryl != 'N' && cheryl!= 'n');<br>
<br>
// End of Rerun Loop<br>
<br>
}<br>
while(cheryl != 'N' && cheryl != 'n');<br>
<br>
<br>
<br>
return 0;<br>
}<br>
<br>
double get_deposit()<br>
{<br>
double hoody_hoo;<br>
do<br>
{<br>
clrscr();<br>
matrix(11);<br>
cout << "\t\t Enter the initial balance: ";<br>
cin >> hoody_hoo;<br>
}<br>
while(hoody_hoo <= 0);<br>
return hoody_hoo;<br>
}<br>
<br>
char get_choice()<br>
{<br>
char blingbling;<br>
do<br>
{<br>
gotoxy(61, 23);<br>
cout << " ";<br>
gotoxy(1, 23);<br>
cout << "\t\t Deposit (D), Withdrawal (W), or Quit (Q): ";<br>
cin >> blingbling;<br>
}<br>
while(blingbling != 'W' && blingbling != 'w' && blingbling != 'D' &&<br>
blingbling != 'd' && blingbling != 'Q' && blingbling != 'q');<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
gotoxy(1, 24);<br>
cout << " ";<br>
cout << " ";<br>
return blingbling;<br>
}<br>
<br>
double get_amount()<br>
{<br>
double btau;<br>
do<br>
{<br>
gotoxy(55, 23);<br>
cout << " ";<br>
gotoxy(1, 23);<br>
cout << "\t\t Enter the amount for the transaction: ";<br>
cin >> btau;<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
gotoxy(1, 24);<br>
cout << " ";<br>
cout << " ";<br>
}<br>
while(btau < 0);<br>
return btau;<br>
}<br>
<br>
void setup()<br>
{<br>
clrscr();<br>
matrix(1);<br>
cout << " Withdrawals Deposits Balance\n";<br>
cout << " ----------- -------- -------\n";<br>
cout.setf(ios::showpoint ¦ ios::fixed);<br>
cout << setprecision(2);<br>
}<br>
<br>
void print_results(double num_w, double num_d, double total,<br>
double total_w, double total_d, double balance,<br>
double initial)<br>
{<br>
clrscr();<br>
matrix(9);<br>
cout << " \t\t Initial Balance:" << setw(18) << initial << '\n';<br>
cout << " \t\t Number of Withdrawals:" << setw(12) << int(num_w) << '\n';<br>
cout << " \t\t Number of Deposits:" << setw(15) << int(num_d) << '\n';<br>
cout << " \t\t Number of Transactions:" << setw(11) << int(total) << '\n';<br>
cout << " \t\t Total of Withdrawals:" << setw(13) << total_w << '\n';<br>
cout << " \t\t Total of Deposits:" << setw(16) << total_d << '\n';<br>
cout << " \t\t Final Balance:" << setw(20) << balance << '\n';<br>
matrix(8);<br>
cout << "\t\t\t Press Enter To Continue: ";<br>
getch();<br>
cin.ignore();<br>
} <br>
<p>Korn<br><a href=mailto:airdevil23@hotmail.com>airdevil23@hotmail.com</a><br><a href= > </a><br>"procrastination is the key to happiness"
Login:A17<br>
Computer#:26<br>
Period:1<br>
Program Title:Check.CPP<br>
Date:11/3/99<br>
<br>
Purpose:This program will allow the user to enter a starting<br>
deposit. It will then process a series of deposits,withdrawals<br>
. Then it will print the # of withdrawals, deposits, transactions<br>
and the total of the withdrawals and deposits.\n";<br>
*/<br>
<br>
<br>
#include "trinity.h"<br>
<br>
void neo();<br>
void morpheus();<br>
double get_deposit();<br>
char get_choice();<br>
double get_amount();<br>
void setup();<br>
void print_results(double num_w, double num_d, double total,<br>
double total_w, double total_d, double balance,<br>
double initial);<br>
<br>
int main()<br>
{<br>
neo();<br>
morpheus();<br>
<br>
// Declaring Variables<br>
double initial, change, total_d, total_w, num_d, num_w, balance, count,total;<br>
char choice, cheryl;<br>
<br>
// Rerun Loop<br>
do<br>
{<br>
<br>
// Initializing Variables<br>
total_d = total_w = num_d = num_w = count = 0;<br>
<br>
// Get initial balance<br>
initial = get_deposit();<br>
balance = initial;<br>
<br>
// Setting up the screen<br>
setup();<br>
<br>
// Do while loop regulating transactions<br>
do<br>
{<br>
// Getting the choice<br>
choice = get_choice();<br>
<br>
// getting amount<br>
if(choice != 'Q' && choice != 'q')<br>
change = get_amount();<br>
<br>
<br>
// Switch regulating options<br>
<br>
switch (choice)<br>
{<br>
case 'D', 'd': total_d = total_d + change;<br>
num_d++;<br>
balance = balance + change;<br>
gotoxy(29, (4 + count));<br>
cout << setw(12) << change;<br>
gotoxy(48, (4 + count));<br>
cout << setw(11) << balance;<br>
count++;<br>
break;<br>
<br>
case 'W', 'w': if(change > balance)<br>
{<br>
gotoxy(1, 23);<br>
cout << " \t\tYou do not have enough. Press Enter";<br>
getch();<br>
cin.ignore();<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
break;<br>
}<br>
<br>
total_w = total_w + change;<br>
num_w++;<br>
balance = balance - change;<br>
gotoxy(9, (4 + count));<br>
cout << setw(15) << change;<br>
gotoxy(48, (4 + count));<br>
cout << setw(11) << balance;<br>
count++;<br>
break;<br>
case 'Q', 'q': break;<br>
}<br>
}<br>
while(choice != 'Q' && choice != 'q');<br>
<br>
// Calculating Total<br>
total = num_d + num_w;<br>
<br>
// Printing the final screen<br>
print_results(num_w, num_d, total, total_w, total_d, balance, initial);<br>
<br>
// Rerun Ask<br>
do<br>
{<br>
cout << "\n\n";<br>
cout << "\t\t Do you want to run this program again(y/n): ";<br>
cin >> cheryl;<br>
}<br>
while(cheryl != 'Y' && cheryl != 'y' && cheryl != 'N' && cheryl!= 'n');<br>
<br>
// End of Rerun Loop<br>
<br>
}<br>
while(cheryl != 'N' && cheryl != 'n');<br>
<br>
<br>
<br>
return 0;<br>
}<br>
<br>
double get_deposit()<br>
{<br>
double hoody_hoo;<br>
do<br>
{<br>
clrscr();<br>
matrix(11);<br>
cout << "\t\t Enter the initial balance: ";<br>
cin >> hoody_hoo;<br>
}<br>
while(hoody_hoo <= 0);<br>
return hoody_hoo;<br>
}<br>
<br>
char get_choice()<br>
{<br>
char blingbling;<br>
do<br>
{<br>
gotoxy(61, 23);<br>
cout << " ";<br>
gotoxy(1, 23);<br>
cout << "\t\t Deposit (D), Withdrawal (W), or Quit (Q): ";<br>
cin >> blingbling;<br>
}<br>
while(blingbling != 'W' && blingbling != 'w' && blingbling != 'D' &&<br>
blingbling != 'd' && blingbling != 'Q' && blingbling != 'q');<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
gotoxy(1, 24);<br>
cout << " ";<br>
cout << " ";<br>
return blingbling;<br>
}<br>
<br>
double get_amount()<br>
{<br>
double btau;<br>
do<br>
{<br>
gotoxy(55, 23);<br>
cout << " ";<br>
gotoxy(1, 23);<br>
cout << "\t\t Enter the amount for the transaction: ";<br>
cin >> btau;<br>
gotoxy(1, 23);<br>
cout << " ";<br>
cout << " ";<br>
gotoxy(1, 24);<br>
cout << " ";<br>
cout << " ";<br>
}<br>
while(btau < 0);<br>
return btau;<br>
}<br>
<br>
void setup()<br>
{<br>
clrscr();<br>
matrix(1);<br>
cout << " Withdrawals Deposits Balance\n";<br>
cout << " ----------- -------- -------\n";<br>
cout.setf(ios::showpoint ¦ ios::fixed);<br>
cout << setprecision(2);<br>
}<br>
<br>
void print_results(double num_w, double num_d, double total,<br>
double total_w, double total_d, double balance,<br>
double initial)<br>
{<br>
clrscr();<br>
matrix(9);<br>
cout << " \t\t Initial Balance:" << setw(18) << initial << '\n';<br>
cout << " \t\t Number of Withdrawals:" << setw(12) << int(num_w) << '\n';<br>
cout << " \t\t Number of Deposits:" << setw(15) << int(num_d) << '\n';<br>
cout << " \t\t Number of Transactions:" << setw(11) << int(total) << '\n';<br>
cout << " \t\t Total of Withdrawals:" << setw(13) << total_w << '\n';<br>
cout << " \t\t Total of Deposits:" << setw(16) << total_d << '\n';<br>
cout << " \t\t Final Balance:" << setw(20) << balance << '\n';<br>
matrix(8);<br>
cout << "\t\t\t Press Enter To Continue: ";<br>
getch();<br>
cin.ignore();<br>
} <br>
<p>Korn<br><a href=mailto:airdevil23@hotmail.com>airdevil23@hotmail.com</a><br><a href= > </a><br>"procrastination is the key to happiness"