CSCI 200 - Fall 2024
Foundational Programming Concepts & Design

A2 - Automated Teller Machine

→This assignment is due by Tuesday, September 24, 2024, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←

Jump To: Rubric Submission

In this assignment, we will combine everything we've learned so far with a focus on conditionals, loops, and functions that accept pointer parameters.


Overview


For this assignment, your job is to create the logic of an Automated Teller Machine. The user will be presented with a menu of options. When the user selects an option, the corresponding function will need to be called.

It may be tempting to store currency as a single floating point value. However, due to precision errors with floats we can sometimes lose money as the errors compound. Instead, it is not uncommon to store dollars and cents separately as two separate integers. This will be the approach that we take.


The Specifics


The following functions must be implemented. Here, the input corresponds to the expected parameters and the output corresponds to the expected return value.

    • Function Name: start_atm
    • Input: None
    • Output: None
    • Description: Contains the logic to display the menu to the user, prompts user for selection, validate user's selection, and calls the corresponding action.

    • Function Name: print_menu
    • Input: None
    • Output: None
    • Description: Prints the menu to the user. The menu should contain four options: (1) Print balance (2) Deposit (3) Withdrawal (Q) Quit.

    • Function Name: get_user_selection
    • Input: None
    • Output: Character representing user's choice
    • Description: Prompts the user to input a value corresponding to the menu selections and returns the user's choice.

    • Function Name: print_balance
    • Input:
      1. An int pointer corresponding to the user's current dollar amount
      2. An int pointer corresponding to the user's current cent amount
    • Output: None
    • Description: Pretty prints the current balance to the screen with a dollar sign and two decimal places along with a friendly message.

    • Function Name: deposit_money
    • Input:
      1. An int pointer corresponding to the user's current dollar amount
      2. An int pointer corresponding to the user's current cent amount
    • Output: None
    • Description: Prompts the user to enter an amount to deposit. Validates both amounts are positive. If the amounts are positive, then modifies the user's balance appropriately.

    • Function Name: withdraw_money
    • Input:
      1. An int pointer corresponding to the user's current dollar amount
      2. An int pointer corresponding to the user's current cent amount
    • Output:
    • Description: Prompts the user to enter an amount to withdraw. Validates both amounts are positive. If the amounts are positive and there is enough money in the account to withdraw, then modifies the user's balance.

With this structure, our main.cpp file will contain nothing more than:

int main() {
    start_atm();
    return 0;
}
All of the logic will be contained within the start_atm() function. A sample run of the program is below with user input italicized for emphasis:

Welcome to the Infinite ATM!
Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 1

You currently have $0.00.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 2

How many dollars would you like to deposit? 4
How many cents would you like to deposit? 50
Thank you for depositing $4.50!

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 1

You currently have $4.50.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 3

How many dollars do you wish to withdraw? 3
How many cents do you wish to withdraw? 0
Here is your $3.00!

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 1

You currently have $1.50.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 3

How many dollars do you wish to withdraw? 3
How many cents do you wish to withdraw? 0
We are sorry, you have insufficient reserves in your treasure store.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 3

How many dollars do you wish to withdraw? -3
How many cents do you wish to withdraw? 0
We are sorry, we are not in the business of giving away money.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 3

How many dollars do you wish to withdraw? 1
How many cents do you wish to withdraw? -10
We are sorry, we are not in the business of giving away money.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 2

How many dollars do you wish to deposit? -5
How many cents do you wish to deposit? 0
It seems you are trying to make a withdrawal.  Perhaps try that instead?

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 7

It is not clear what you are trying to do.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 2

How many dollars do you wish to deposit? 0
How many cents do you wish to deposit? 75
Thank you for depositing $0.75!

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 1

You currently have $2.25.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 3

How many dollars do you wish to withdraw? 0
How many cents do you wish to withdraw? 221
Here is your $2.21!

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: 1

You currently have $0.04.

Please make a selection:
(1) Print Current Balance
(2) Deposit
(3) Withdraw
(Q) Quit
Choice: Q

Thanks for coming!

You do not need to match the text of the prompts exactly but you must match the functionality presented above.


Functional Requirements



Grading Rubric


Your submission will be graded according to the following rubric:

PointsRequirement Description
0.5Submitted correctly by Tuesday, September 24, 2024, 11:59 PM
0.5Project builds without errors nor warnings.
2.0Best Practices and Style Guide followed.
0.5Program follows specified user I/O flow.
0.5Public and private tests successfully passed.
2.0Fully meets specifications.
6.00Total Points


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, atmFunctions.h, atmFunctions.cpp, Makefile files and name the zip file A2.zip. Upload this zip file to Canvas under A2.


→This assignment is due by Tuesday, September 24, 2024, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←