Design a simple ATM service kiosk. This kiosk supports the following options for
ID: 3551434 • Letter: D
Question
Design a simple ATM service kiosk. This kiosk supports the following options for its menu: 1. Viewing your account balance
2. Depositing cash
3. Withdrawing cash
4. Leave kiosk
Initially, the account balance is $0.00. When you deposit cash, this account balance is increased by your deposit amount. Similarly, when you withdraw cash, this account balance is decreased by your withdrawal amount. You cannot withdraw more than what exists in the account. Similarly, you cannot deposit a negative cash amount. Use a switch statement to perform the respective operation in the menu. The ATM kiosk provides these three options until the user selects the option to leave the kiosk. At the end of every transaction, the user is being asked if they need to perform another transaction. Use a do-while to satisfy this last requirement.
Example and expected output:
Explanation / Answer
#include<stdio.h>
int main()
{
int ch;
float amount=0.0,deposit,withd;
int loop=0;
printf("Welcome to ACME ATM ");
while(1)
{if(loop==1)
break;
printf("1. View your Balance ");
printf("2. Dwposit Cash ");
printf("3. Withdraw cash ");
printf("4. Exit ");
printf(" Enter your selection : ");
scanf("%d",&ch);
switch(ch)
{case 1:
printf(" Your current balance is %f",amount );
break;
case 2:
printf(" Enter the amount you want to deposit : ");
scanf("%f",&deposit);
amount+=deposit;
break;
case 3:
printf(" Enter the amount you want to withdraw : ");
scanf("%f",&withd);
if(withd>amount)
printf(" Sorry you don't have enough balance! ");
else
amount-=withd;
break;
case 4:
loop=1;
break;
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.