upload
This commit is contained in:
parent
68e45dd3b5
commit
bf1c77bd06
3 changed files with 114 additions and 112 deletions
|
@ -11,7 +11,7 @@
|
||||||
* @param pDollars A pointer to the amount of dollars
|
* @param pDollars A pointer to the amount of dollars
|
||||||
* @param pCents A pointer to the amount of cents
|
* @param pCents A pointer to the amount of cents
|
||||||
*/
|
*/
|
||||||
void normalize_dollars(int* pDollars, int* pCents) {
|
void normalize_dollars(int *pDollars, int *pCents) {
|
||||||
*pDollars += *pCents / 100;
|
*pDollars += *pCents / 100;
|
||||||
*pCents = *pCents % 100;
|
*pCents = *pCents % 100;
|
||||||
}
|
}
|
||||||
|
@ -71,14 +71,14 @@ char get_user_selection() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_balance(int* pDollars, int* pCents) {
|
void print_balance(int *pDollars, int *pCents) {
|
||||||
std::cout << "Your account currently contains a total of $" << *pDollars
|
std::cout << "Your account currently contains a total of $" << *pDollars
|
||||||
<< "." << std::setfill('0') << std::setw(2) << *pCents << "."
|
<< "." << std::setfill('0') << std::setw(2) << *pCents << "."
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deposit_money(int* pDollars, int* pCents) {
|
void deposit_money(int *pDollars, int *pCents) {
|
||||||
// Prompt the user for the amount to deposit
|
// Prompt the user for the amount to deposit
|
||||||
int dollarsToDeposit = 0, centsToDeposit = 0;
|
int dollarsToDeposit = 0, centsToDeposit = 0;
|
||||||
std::cout << "How many dollars would you like to deposit? ";
|
std::cout << "How many dollars would you like to deposit? ";
|
||||||
|
@ -111,7 +111,7 @@ void deposit_money(int* pDollars, int* pCents) {
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void withdraw_money(int* pDollars, int* pCents) {
|
void withdraw_money(int *pDollars, int *pCents) {
|
||||||
// Prompt the user for the amount to withdraw
|
// Prompt the user for the amount to withdraw
|
||||||
int dollarsToWithdraw = 0, centsToWithdraw = 0;
|
int dollarsToWithdraw = 0, centsToWithdraw = 0;
|
||||||
std::cout << "How many dollars would you like to withdraw? ";
|
std::cout << "How many dollars would you like to withdraw? ";
|
||||||
|
@ -120,7 +120,8 @@ void withdraw_money(int* pDollars, int* pCents) {
|
||||||
std::cin >> centsToWithdraw;
|
std::cin >> centsToWithdraw;
|
||||||
|
|
||||||
if (centsToWithdraw < 0 || dollarsToWithdraw < 0) {
|
if (centsToWithdraw < 0 || dollarsToWithdraw < 0) {
|
||||||
std::cout << "Withdrawals must be positive amounts, please try again with "
|
std::cout
|
||||||
|
<< "Withdrawals must be positive amounts, please try again with "
|
||||||
"proper values"
|
"proper values"
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
@ -136,7 +137,8 @@ void withdraw_money(int* pDollars, int* pCents) {
|
||||||
*pDollars = 0;
|
*pDollars = 0;
|
||||||
|
|
||||||
if (totalCentWithdrawal > *pCents) {
|
if (totalCentWithdrawal > *pCents) {
|
||||||
std::cout << "You do not have enough money for this withdrawal" << std::endl
|
std::cout << "You do not have enough money for this withdrawal"
|
||||||
|
<< std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ char get_user_selection();
|
||||||
* @param dollars The amount of full dollars the user currently has
|
* @param dollars The amount of full dollars the user currently has
|
||||||
* @param cents The amount of cents the user currently has
|
* @param cents The amount of cents the user currently has
|
||||||
*/
|
*/
|
||||||
void print_balance(int* pDollars, int* pCents);
|
void print_balance(int *pDollars, int *pCents);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prompts the user an amount to deposit, validates it, and modifies the
|
* @brief Prompts the user an amount to deposit, validates it, and modifies the
|
||||||
|
@ -38,7 +38,7 @@ void print_balance(int* pDollars, int* pCents);
|
||||||
* @param dollars The amount of full dollars the user currently has
|
* @param dollars The amount of full dollars the user currently has
|
||||||
* @param cents The amount of cents the user currently has
|
* @param cents The amount of cents the user currently has
|
||||||
*/
|
*/
|
||||||
void deposit_money(int* pDollars, int* pCents);
|
void deposit_money(int *pDollars, int *pCents);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prompts the user an amount to withdraw, validates it, and modifies the
|
* @brief Prompts the user an amount to withdraw, validates it, and modifies the
|
||||||
|
@ -47,6 +47,6 @@ void deposit_money(int* pDollars, int* pCents);
|
||||||
* @param dollars The amount of full dollars the user currently has
|
* @param dollars The amount of full dollars the user currently has
|
||||||
* @param cents The amount of cents the user currently has
|
* @param cents The amount of cents the user currently has
|
||||||
*/
|
*/
|
||||||
void withdraw_money(int* pDollars, int* pCents);
|
void withdraw_money(int *pDollars, int *pCents);
|
||||||
|
|
||||||
#endif // ATMFUNCTIONS_H
|
#endif // ATMFUNCTIONS_H
|
||||||
|
|
Loading…
Reference in a new issue