149k views
1 vote
C++

ATM PROGRAM DESIGN Ask the user to enter the desired withdrawal amount in multiple of 10 dollars. The algorithm should determine the least number of bills dispensed. The bills dispensed are 50s, 20s, and 10s. For example, if the withdrawal amount is 110 dollars, your program would say that the machine will dispense 2 fifties, 0 twenties, and 1 ten.  Display the number dispensed for each bill type after the user enters a dollar amount (only if a valid dollar amount is entered).  The program should include a welcome message that gives a brief description of what the program does.  Create named constants in ALL CAPS for each of the dollar amounts of 10, 20 and 50.  Display an error message if the dollar amount is not greater than zero or if the amount is not a multiple of ten.  Hint: You will need to use the modulus (%) operator for some of the calculations.

User Jprusakova
by
7.5k points

1 Answer

4 votes

Final answer:

To create an ATM program in C++, prompt the user to enter a withdrawal amount in multiples of 10 dollars. Use constants for bill denominations and provide error messages for invalid inputs. Ensure the least number of bills are dispensed using an efficient algorithm.

Step-by-step explanation:

ATM Algorithm in C++

To design an ATM program in C++, you first need to ask the user to enter the desired withdrawal amount in multiple of 10 dollars. It is important to implement the algorithm to determine the least number of bills dispensed for $50, $20, and $10 denominations. Here's a structure to guide the creation of this program:





An example logic for the core part of the program is:


  1. Check if the entered amount is valid.

  2. Calculate how many $50 bills by dividing the withdrawal amount by 50.

  3. Calculate remaining amount using modulus operator.

  4. Determine $20 bills in similar fashion and update the remaining amount.

  5. Finally, the remaining amount will be the number of $10 bills.

User Millerf
by
8.5k points