-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbankinterestswitch.c
51 lines (40 loc) · 1.26 KB
/
bankinterestswitch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* BankInterest.c to compute and display interest on bank account */
#include <stdio.h>
int main(void)
{
int per;
double amount, int_rate, interest,newrate;
/* get the input: amount, int_rate, period */
printf("Enter the principal amount deposited (in $): ");
scanf("%lf", &amount);
printf("Enter the basic annual interest rate (in %%): ");
scanf("%lf", &int_rate);
printf("Enter the deposit period (in months): ");
scanf("%d", &per);
switch (per)
{
case 15<=per<24 :
newrate=1+int_rate;
/* compute the interest */
interest = amount*(newrate/100.0)*(per/12.0);
/* output the result */
printf("The interest due is $%.2f\n\n", interest);
break;
case per == 24 :
newrate=1.25+int_rate;
/* compute the interest */
interest = amount*(newrate/100.0)*(per/12.0);
/* output the result */
printf("The interest due is $%.2f\n\n", interest);
break;
case per<24 :
newrate=1.25+int_rate;
/* compute the interest */
interest = amount*(newrate/100.0)*(per/12.0);
/* output the result */
printf("The interest due is $%.2f\n\n", interest);
break;
default:
printf("These loans are not given out by the bank lol");
return 0;
}