Submit a hard copy with algorithms (algorithm format specified below for each pr
ID: 2247983 • Letter: S
Question
Submit a hard copy with algorithms (algorithm format specified below for each program). Submit your code and screen shots showing the various test case inputs and outputs. Don't forget to include your header comments, any other useful comments, and to indent properly. If you are submitting late, you must upload to Moodle before 11:55 p.m. on the late due date. In this assignment you will be writing 2 programs. Program 2.1. Write a simple ATM machine program. Initialize four variables to hold the account number (a 10-digit number), the name of the account holder's name (the variable should be able to hold names up to 25 characters in length), the passcode (a 6-digit number), and the balance of a bank account. Normally this information would be stored in a database in the banks computer and the program would retrieve the information from the database. However, you'll just choose values for testing and initialize the variables to these values. Create another two variables to hold the values that the user will enter for account number and passcode. Determine what would be the best data type for each of these variables (Choose from the following: char, int, short, long long, float, double, and string/character array). Your program should display a message indicating that this is an ATM. You can name the bank. Ex: "Welcome to Rainbow Bank's ATM" Next the program should prompt the bank customer for their account number. If the account number matches the stored account number, you should prompt them to enter their passcode. If it doesn't, display an appropriate error message. Ex: "Error: I program should exit. If the account number and passcode are correct, display a welcome message. Ex: welcome Joe, how can I help you today?" (Assuming the account holder's name is Joe). If the passcode is incorrect, display an appropriate error message and then exit the program. nvalid account number" and the · Next, give the bank customer three options. 1-Check account balance. 2 - Deposit cash. 3 - Withdraw cash. Please specify your selection Ex: If the customer selects 1, display the account balance. If the customer selects 2, ask the customer how much they would like to deposit, add it to the account balance, and display the new balance. e customer selects 3, ask how much the customer wants to withdraw and check to see if there is enough money. If there isn't, tell the customer that they do not have enough money and exit. If there is enough money, subtract the amount withdrawn from the balance and display the new balance. If thExplanation / Answer
ATM Machine Program
1. Firstly initialize the ATM pin and amount with some random number.
2. Take the ATM pin as input.
3. If the input pin is equal to the initialized pin, then do the further operations.
4. Use switch statement to do the operations like Balance checking, Cash withdrawal, Cash deposition etc.
5. Use while loop to terminate or restart the process.
* C Program to Display the ATM Transaction
4.#include <stdio.h>
unsigned long amount=1000, deposit, withdraw;
int choice, pin, k;
char transaction ='y';
void main()
{
while (pin != 1520)
{
printf("ENTER YOUR SECRET PIN NUMBER:");
scanf("%d", &pin);
if (pin != 1520)
printf("PLEASE ENTER VALID PASSWORD ");
}
do
{
printf("********Welcome to ATM Service************** ");
printf("1. Check Balance ");
printf("2. Withdraw Cash ");
printf("3. Deposit Cash ");
printf("4. Quit ");
printf("******************?**************************?* ");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf(" YOUR BALANCE IN Rs : %lu ", amount);
break;
case 2:
printf(" ENTER THE AMOUNT TO WITHDRAW: ");
scanf("%lu", &withdraw);
if (withdraw % 100 != 0)
{
printf(" PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
}
else if (withdraw >(amount - 500))
{
printf(" INSUFFICENT BALANCE");
}
else
{
amount = amount - withdraw;
printf(" PLEASE COLLECT CASH");
printf(" YOUR CURRENT BALANCE IS%lu", amount);
}
break;
case 3:
printf(" ENTER THE AMOUNT TO DEPOSIT");
scanf("%lu", &deposit);
amount = amount + deposit;
printf("YOUR BALANCE IS %lu", amount);
break;
case 4:
printf(" THANK U USING ATM");
break;
default:
printf(" INVALID CHOICE");
}
printf(" DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): ");
fflush(stdin);
scanf("%c", &transaction);
if (transaction == 'n'|| transaction == 'N')
k = 1;
} while (!k);
printf(" THANKS FOR USING OUT ATM SERVICE");
}
Program Explanation
1. Initialize the variables pin, amount and transaction with 1520, 1000 and ‘y’ respectively.
2. Ask for the pin from user. If the input pin is equal to 1520, then allow for the further operations.
3. Use switch statement to do the operations like Check Balance, Withdraw Cash, Deposit Cash and Quit.
4. For Check Balance simply print the variable amount as output and exit.
5. For Withdraw Cash, first ask the amount to withdraw and store it in the variable withdraw.
6. If withdraw % 100 != 0, then ask user to enter the amount in multiplies of 100.
7. If withdraw amount is greater than (amount-500), then print the output as “INSUFFICENT BALANCE”.
8. Otherwise subtract the variable withdraw from variable amount, print the amount and exit.
9. For deposit operation, ask the user for amount and store it in the variable deposit.
10. Add the variable deposit to variable amount, print the amount and exit.
11. If quit, then finally ask the user if they wish to continue or not. Ask them to type y/n and store it in the variable transaction.
12. If variable transaction is y/Y, then continue the operation. Otherwise terminate the while loop by assigning 1 to variable k.
Compass Program