CSCI 261 - Programming Concepts

Fall 2018 - A4 - ATM

Quick Links: Canvas | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |

This assignment is due by Tuesday, October 2, 2018, 11:59 PM.

· Instructions · Rubric · Submission ·


In this homework, we will combine everything we've learned so far with a focus on conditionals, loops, and functions.


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.


The Specifics



The following functions must be implemented:
    • Function Name: startATM
    • Input: None
    • Output: None
    • Description: Contains the logic to display the menu to the user, prompts user for selection, validate user's selection, calls the corresponding action, and confirms the result of that action (either success or failure).

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

    • Function Name: getUserSelection
    • Input: None
    • Output: Integer representing user's choice
    • Description: Prompts the user to input a value corresponding to the menu selections

    • Function Name: printBalance
    • Input: Double passed by constant value representing the user's current balance
    • 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
    • Input: Double passed by reference representing the user's current balance
    • Output: Double representing the amount deposited
    • Description: Prompts the user to enter a positive amount to deposit. Validates the amount is positive. If the amount is positive, then modifies the user's balance and returns the amount deposited. Otherwise, returns a value signifying there was an error.

    • Function Name: withdraw
    • Input: Double passed by reference representing the user's current balance
    • Output: Double representing the amount withdrawn
    • Description: Prompts the user to enter a positive amount to withdraw. Validates there is enough money in the account to withdraw. If there is enough balance, then modifies the user's balance and returns the amount withdrawn. Otherwise, returns a value signifying there was an error.

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

int main() {
  startATM();
  return 0;
}

All of the logic will be contained within the startATM() 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 Dubloons
    (3) Withdraw Dubloons
    (4) Quit
    Choice: 1

    You currently have $0.00.

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

    How many dubloons would you like to deposit?
    4.50
    Thank you for depositing $4.50 dubloons!

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

    You currently have $4.50.

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

    How much do you wish to take out?
    3
    Here are your $3.00 dubloons!

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

    You currently have $1.50.

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

    How much do you wish to take out?
    3
    We are sorry, you have insufficient reserves in your treasure store.

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

    How much do you wish to take out?
    -3
    We are sorry, we are not in the business of giving away money.

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

    How many dubloons would you like to deposit?
    -5
    It seems you are trying to make a withdrawal.  Perhaps try that instead?

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

    It is not clear what you are trying to do.

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

    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



  • Do not use global variables! If you are using a global variable in multiple functions, then you should be passing that variable into the function. If you use global variables, you will lose points so get out of the global variable shorcut habit.
  • All functions must be placed in a separate file.
  • Do not use the goto command. You will lose points for using goto. You must structure your loops and conditionals properly to receive full credit.


Hints



  • You will need to use loops (perhaps while and/or do-while), branching, and functions to complete this assignment.
  • Write out pseudocode before starting.
  • Do not wait until the day before this is due to begin.


Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement Description
2 All code submitted properly.
8 All labs completed and submitted
4 Functional requirements above met.
10 Functions are implemented correctly and match specifications.
3 ATM logic validates and handles errors appropriately.
2 (1) Comments used
(2) Coding style followed
(3) Appropriate variable names, constants, and data types used
(4) Instructions followed
29 Total Points

This assignment is due by Tuesday, October 2, 2018, 11:59 PM.


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. The following instructions are copied from How to Submit Homework.


It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work. And that makes us very unhappy. And when we're unhappy, we give penalties. Thus, make us happy.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:
  1. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set4
    2. Inside Set4, create 5 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L4A, L4B, L4C, L4D, and A4).
    3. Copy your main.cpp , additional header & source files, plus the CMakeLists.txt file into the subdirectories of Set4 (steps 1-2), zip this Set4 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
    4. For example, when you zip/submit Set4, there will be 5 sub-folders called L4A, L4B, L4C, L4D, and A4 inside the Set4 folder, and each of these sub-folders will have a file called main.cpp, additional header & source files, plus the CMakeLists.txt file .

  2. Using Windows Explorer (not to be confused with Internet Explorer), find the file named "main.cpp" located inside the folder for the particular lab or homework assignment you will submit.

    STOP: Are you really sure you are viewing the correct assignment's folder?

  3. Now, for A4, right click on the main.cpp to copy the file. Then, return to the Set4/A4 folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code into the Set4/A4 folder. Repeat this for each additional header & source file you have with this assignment, plus CMakeLists.txt.

    Follow the same steps for L4A, to put a copy of your lab's main.cpp into the Set4/L4A folder. Repeat this process for Set4/L4B, Set4/L4C, Set4/L4D.

    STOP: Are you sure your Set4 folder now has all your code to submit?

  4. Now, right-click on the "Set4" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set4 folder with sub-folders that each contain a main.cpp file in it?

  5. After the previous step, you should now see a "Set4.zip" file.

  6. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  7. Find Set4, click on it, find the "Submist Assignment" area, and then click the "Choose File" button.

  8. Find the "Set4.zip" file created earlier and click the "Open" button.

    STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?

  9. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  10. No, really, make sure you click the "Submit Assignment" button to actually submit your homework. Clicking the "Choose File" button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!

  11. Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set4" folder and only the "Set4" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this homework, and you must click the "Submit Assignment" button. Not doing these steps is like bringing your homework to class but forgetting to hand it in. No concessions will be made for incorrectly submitted work. If you incorrectly submit your homework, we will not be able to give you full credit. And that makes us unhappy.


This assignment is due by Tuesday, October 2, 2018, 11:59 PM.

Last Updated: 09/26/18 19:54


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0