write in C programing languageand also use functions output
*** write in C programing language...and also use functions
output will be like following: (bold letters are input)
***** Welcome to Savings Account Banking *****
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 5
-- Account information --
Account# Balance
-------- ----------
11111111 123.45
22222222 12365.50
33333333 0.00
44444444 1475.00
55555555 25000.65
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 1
-- Make a deposit --
Enter account number: 44444444
Enter amount to deposit (CAD): 20
Current balance is : 1495.00
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 1
-- Make a deposit --
Enter account number: 11111111
Enter amount to deposit (CAD): 450.67
Current balance is : 574.12
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 5
-- Account information --
Account# Balance
-------- ----------
11111111 574.12
22222222 12365.50
33333333 0.00
44444444 1495.00
55555555 25000.65
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 3
-- Add monthly interest earnings to all accounts --
Account# New Balance Interest Earnings (M)
-------- ----------- ---------------------
11111111 583.65 9.53
22222222 12673.40 307.90
33333333 0.00 0.00
44444444 1519.82 24.82
55555555 25623.17 622.52
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 5
-- Account information --
Account# Balance
-------- ----------
11111111 583.65
22222222 12673.40
33333333 0.00
44444444 1519.82
55555555 25623.17
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 2
-- Withdraw funds --
Enter account number: 67676767
ERROR: Account number does not exist.
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 2
-- Withdraw funds --
Enter account number: 11111111
Enter amount to withdraw (CAD): 250
Current balance is : 333.65
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 2
-- Withdraw funds --
Enter account number: 33333333
Enter amount to withdraw (CAD): 4500.56
Withdrawal failed. You only have : 0.00 in your account
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 2
-- Withdraw funds --
Enter account number: 55555555
Enter amount to withdraw (CAD): 6200.40
Current balance is : 19422.77
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 5
-- Account information --
Account# Balance
-------- ----------
11111111 333.65
22222222 12673.40
33333333 0.00
44444444 1519.82
55555555 19422.77
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 4
-- Apply service charges to all accounts --
Account# New Balance Service charges (M)
-------- ----------- -------------------
11111111 326.15 7.50
22222222 12670.90 2.50
33333333 -7.50 7.50
44444444 1517.32 2.50
55555555 19420.27 2.50
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 5
-- Account information --
Account# Balance
-------- ----------
11111111 326.15
22222222 12670.90
33333333 -7.50
44444444 1517.32
55555555 19420.27
1.) Deposit
2.) Withdraw
3.) Apply monthly interest earnings to all accounts
4.) Apply service charges to all accounts
5.) Account Summary
0.) Log out
Please enter an option to continue: 0
Solution
#include <stdio.h>
struct account{
int acNum;
double balance;
};
void displayAll(struct account arr[], int size){
printf(\"Account# \\tBalance\ \");
printf(\"-------- \\t-------\ \");
int i;
for(i = 0; i < size; i++){
printf(\"%d\\t%.2lf\ \", arr[i].acNum, arr[i].balance);
}
printf(\"\ \");
}
int menu(){
printf(\"1.) Deposit\ 2.) Withdraw\ 3.) Apply monthly interest earnings to all accounts\ 4.) Apply service charges to all accounts\ 5.) Account Summary\ 0.) Log out\ \ Please enter an option to continue: \");
int n;
scanf(\"%d\", &n);
printf(\"\ \");
return n;
}
int search(struct account arr[], int size, int acc){
int i;
for(i = 0; i < size; i++){
if(arr[i].acNum == acc) return i;
}
return -1;
}
void addInterest(struct account arr[], int size){
int i;
printf(\"Account# \\tNew Balance\\tInterest Earnings (M)\ \");
printf(\"-------- \\t-----------\\t---------------------\ \");
for(i = 0; i < size; i++){
double interest;
if(arr[i].balance >= 10000) interest = 0.02429 * arr[i].balance;
else interest = 0.01633 * arr[i].balance;
arr[i].balance += interest;
printf(\"%d\\t%.2lf\\t\\t%.2lf\ \", arr[i].acNum, arr[i].balance, interest);
}
printf(\"\ \");
}
void applyServiceCharges(struct account arr[], int size){
int i;
printf(\"Account# \\tNew Balance\\tService charges (M)\ \");
printf(\"-------- \\t-----------\\t-------------------\ \");
for(i = 0; i < size; i++){
double charge;
if(arr[i].balance >= 1000) charge = 2.50;
else charge = 7.50;
arr[i].balance -= charge;
printf(\"%d\\t%.2lf\\t\\t%.2lf\ \", arr[i].acNum, arr[i].balance, charge);
}
printf(\"\ \");
}
int main(){
printf(\"***** Welcome to Savings Account Banking *****\ \ \");
int accountNum, index = -1;
double amount;
struct account array[] = {{11111111, 123.45}, {22222222, 12365.50}, {33333333, 0}, {44444444, 1475.00}, {55555555, 25000.65}};
while(1){
int choice = menu();
switch(choice){
case 1:
printf(\"-- Make a deposit --\ \ \");
printf(\"Enter account number: \");
scanf(\"%d\", &accountNum);
index = search(array, 5, accountNum);
if(index == -1){
printf(\"ERROR: Account number does not exist.\ \ \");
break;
}
printf(\"Enter amount to deposit (CAD): \");
scanf(\"%lf\", &amount);
array[index].balance += amount;
printf(\"Current balance is : %.2lf\ \ \", array[index].balance);
break;
case 2:
printf(\"-- Withdraw funds --\ \ \");
printf(\"Enter account number: \");
scanf(\"%d\", &accountNum);
index = search(array, 5, accountNum);
if(index == -1){
printf(\"ERROR: Account number does not exist.\ \ \");
break;
}
printf(\"Enter amount to withdraw (CAD): \");
scanf(\"%lf\", &amount);
if(array[index].balance < amount){
printf(\"Withdrawal failed. You only have : %.2lf in your account\ \ \", array[index].balance);
break;
}
array[index].balance -= amount;
break;
case 3:
printf(\"-- Add monthly interest earnings to all accounts --\ \ \");
addInterest(array, 5);
break;
case 4:
printf(\"-- Apply service charges to all accounts --\ \ \");
applyServiceCharges(array, 5);
break;
case 5:
printf(\"-- Account information --\ \ \");
displayAll(array, 5);
break;
case 0:
return 0;
}
}
}







