Problem 5: A bank in your town updates its customers\' account at the end of eac
ID: 3889711 • Letter: P
Question
Problem 5: A bank in your town updates its customers' account at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer balance falls below the minimum balance, there is a service charge of $10.00 for savings accounts and $25.00 dollars for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows: 1. 2. savings accounts receive 4% interest. checking accounts with a balance up to $5,000 more than the minimum balance receive 3% interest; otherwise the interest is 5% write a program that reads a customer's account number (int type), account type (char; s for savings, c for checking), minimum balance that the account should maintain, and current balance. The program should then output the account number, account type, current balance, and an appropriate message. Test your program by running it five time using the following data 46728 S 1000 2700 87324 c 1500 7689 79873 S 1000 800 89832 C 2000 3000 98322 1000 750Explanation / Answer
PLEASE REFER BELOW CODE
#include<stdio.h>
#include<stdlib.h>
void print_data(int acc_no, char type, float min_balance, float current_balance)
{
printf(" =============================================== ");
printf("Account Number = %d ", acc_no);
if(type == 'c')
printf("Account type = Current ");
else
printf("Account type = Savings ");
printf("Minimum balance to maintain = $%.3f ", min_balance);
printf("Current balance = $%.3f ", current_balance);
}
int main()
{
int acc_no;
char type;
float test,min_balance,curr_balance,final_bal;
//taking user data
printf("Enter account Number : ");
scanf("%d", &acc_no);
printf(" Enter account type savings:'s' current:'c' : ");
scanf(" %c", &type);
printf(" Enter minimum balance to maintain : ");
scanf("%f", &min_balance);
printf(" Enter current balance : ");
scanf("%f", &curr_balance);
//If account type is saving
if(type == 's')
{
if(min_balance > curr_balance) //current balance is less than minumum balance
{
final_bal = curr_balance - 10;
print_data(acc_no, type, min_balance, final_bal);
printf("Amount $10 is debited from account due to insufficient balance ");
}
else //add 4% interest to current balance
{
test = curr_balance * 0.04;
final_bal = test + curr_balance;
print_data(acc_no, type, min_balance, final_bal);
printf("$%.3f credited to your account ", test);
}
}
//if account type is current
else
{
if(min_balance > curr_balance) //current balance is less than minumum balance
{
final_bal = curr_balance - 25;
print_data(acc_no, type, min_balance, final_bal);
printf("Amount $25 is debited from account due to insufficient balance ");
}
else
{
if(curr_balance <= (min_balance + 5000)) //if current balance is upto 5000 more than min balance then 3% interest
{
test = curr_balance * 0.03;
final_bal = curr_balance + test;
print_data(acc_no, type, min_balance, final_bal);
printf("$%.3f credited to your account ", test);
}
else
{
test = curr_balance * 0.05;
final_bal = curr_balance + test;
print_data(acc_no, type, min_balance, final_bal);
printf("$%.3f credited to your account ", test);
}
}
}
return 0;
}
PLEASE REFER BELOW OUTPUT
Enter account Number : 46728
Enter account type savings:'s' current:'c' : s
Enter minimum balance to maintain : 1000
Enter current balance : 2700
===============================================
Account Number = 46728
Account type = Savings
Minimum balance to maintain = $1000.000
Current balance = $2808.000
$108.000 credited to your account
Process returned 0 (0x0) execution time : 13.767 s
Press any key to continue.
----------------------------------------------------------------------------------------------------------------
Enter account Number : 87324
Enter account type savings:'s' current:'c' : c
Enter minimum balance to maintain : 1500
Enter current balance : 7689
===============================================
Account Number = 87324
Account type = Current
Minimum balance to maintain = $1500.000
Current balance = $8073.450
$384.450 credited to your account
Process returned 0 (0x0) execution time : 21.098 s
Press any key to continue.
------------------------------------------------------------------------------------------------------------------
Enter account Number : 79873
Enter account type savings:'s' current:'c' : s
Enter minimum balance to maintain : 1000
Enter current balance : 800
===============================================
Account Number = 79873
Account type = Savings
Minimum balance to maintain = $1000.000
Current balance = $790.000
Amount $10 is debited from account due to insufficient balance
Process returned 0 (0x0) execution time : 14.165 s
Press any key to continue.
-----------------------------------------------------------------------------------------------------------
Enter account Number : 89832
Enter account type savings:'s' current:'c' : c
Enter minimum balance to maintain : 2000
Enter current balance : 3000
===============================================
Account Number = 89832
Account type = Current
Minimum balance to maintain = $2000.000
Current balance = $3090.000
$90.000 credited to your account
Process returned 0 (0x0) execution time : 18.153 s
Press any key to continue.
-----------------------------------------------------------------------------------------------
Enter account Number : 98322
Enter account type savings:'s' current:'c' : c
Enter minimum balance to maintain : 1000
Enter current balance : 750
===============================================
Account Number = 98322
Account type = Current
Minimum balance to maintain = $1000.000
Current balance = $725.000
Amount $25 is debited from account due to insufficient balance
Process returned 0 (0x0) execution time : 11.770 s
Press any key to continue.