Question: In C++ ONLY In this homework, we will combine everything we've learned so far with a focus on conditionals, loops, and functions. Overview For this

In C++ ONLY

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!