I am trying to complete this Creat a New Bank Account code in C programming. The
ID: 3842718 • Letter: I
Question
I am trying to complete this Creat a New Bank Account code in C programming. The code has 7 cases listed as;
1. Creat New Account
2. Cash Deposit
3. Cash Withdrawal
4. Fund Transfer
5. Account Information
6. Transaction Information
7. Exit
Press a choice between the range [1-7]
The above is what the menu screen should look like. When the numbers [1-7] is press that screen will display plus Press any key to continue.
When [7] is pressed I get the prompt, "Are you sure you want to exit?" <Y/N>. If [8] is pressed the display will state, You are out of range enter a number betwen [1-7].
Note: This code needs no account names or numbers.
Explanation / Answer
Find below the program coding:
#include<stdio.h>
#include<stdlib.h>
float sum=0;
void bal(float wamo){
if(sum > wamo){
sum = sum-wamo;
printf("Your balance is %f", sum);
}else{
printf(" Insufficient balance");
}
}
void main() {
int n;
float amo,wamo,transwamo;
char ch;
do{
printf("Press a Choice between the Range[1-7] ");
printf("1. Create New Account 2. Cash Deposit 3. Cash Withdrawal 4. Fund Transfer 5. Account Information 6. Transaction Information 7. Exit");
scanf("%d", &n);
switch(n){
case 1: printf(" New Account Created");
break;
case 2: printf(" Enter amount to be deposit");
scanf("%f", &amo);
sum = sum+amo;
printf(" Your balance is %f", sum);
break;
case 3: printf(" Enter amount to be Withdrawal");
scanf("%f", &wamo);
bal(wamo);
break;
case 4: printf(" Enter amount to be transfer");
scanf("%f", &transwamo);
bal(transwamo);
break;
case 5 : printf(" Account information");
bal(0);
break;
case 6: printf(" Transaction information");
bal(0);
break;
case 7:
printf(" Are you sure you want to exit?<Y/N>");
scanf("%c",&ch);
if(ch=='y' || ch=='Y'){
exit(0);
}
break;
case 8:
printf(" You are out of range enter a number between [1-7]");
break;
}
}while(n < 9);
}
OUTPUT:
Press a Choice between the Range[1-7]
1. Create New Account
2. Cash Deposit
3. Cash Withdrawal
4. Fund Transfer
5. Account Information
6. Transaction Information
7. Exit
New Account Created
Press a Choice between the Range[1-7]
1. Create New Account
2. Cash Deposit
3. Cash Withdrawal
4. Fund Transfer
5. Account Information
6. Transaction Information
7. Exit
Enter amount to be deposit 100
Your balance is 100.000000