-
Notifications
You must be signed in to change notification settings - Fork 0
/
FuLi3.0.cpp
144 lines (106 loc) · 2.23 KB
/
FuLi3.0.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include<stdio.h>
#include<math.h>
float i,p,w,f,k;
double d,m,b,t,y;
int n;
void principal()
{
printf("输入您的本金:");
scanf("%f",&p);
printf("输入您期望的利率:");
scanf("%f",&i);
printf("输入您期望的存入期数:");
scanf("%d",&n);
w=p*pow((1+i),n);
printf("计算结果为:%f\n",w);
}
void FutureMoney()
{
printf("输入您需要筹得的金额:");
scanf("%f",&w);
printf("输入您期望的利率:");
scanf("%f",&i);
printf("输入您期望的存入期数:");
scanf("%d",&n);
p = w/pow((1+i),n);
printf("您需要存的本金是:%f\n",p);
}
void SimpleInterest()
{
printf("输入您的本金:");
scanf("%f",&p);
printf("输入您期望的利率:");
scanf("%f",&i);
printf("输入您期望的存入期数:");
scanf("%d",&n);
w=p*i*n;
printf("计算结果为:%f\n",w);
}
void Time()
{
printf("输入您的本金:");
scanf("%f",&p);
printf("输入您期望的利率:");
scanf("%f",&i);
printf("输入您期盼的总金额:");
scanf("%f",&f);
printf("输入您的复利次数:");
scanf("%f",&k);
w=log(f/p)/log(i/k+1)/k;
printf("您所需要存的年限为:%f\n",w);
}
void Rate()
{
printf("输入您期盼的存入期数(年):");
scanf("%lf",&d);
printf("输入您的本金:");
scanf("%lf",&m);
printf("输入您期盼的总金额:");
scanf("%lf",&t);
b= (double) (((t-m)/m)/d);
printf("您应该要的利率为:%lf\n",b);
}
void Manytimes()
{
printf("输入您期盼的存入期数(年):");
scanf("%lf",&y);
printf("输入本金金额:");
scanf("%lf",&m);
printf("输入年利率:");
scanf("%lf",&b);
t=m*pow(1+b,y);
printf("%lf年后,您能够得到%lf的总资产\n",y,t);
}
void main(void){
printf("\n【复利计算程序】\n");
int m;
printf("\n复利计算按 1\n单利计算按 2\n计算筹集的养老金按 3\n计算时间按 4\n计算您要的利率按 5\n计算本利和投资按 6\n\n");
do
{ scanf("%d",&m);
if(m == 1)
{
principal();
}
if(m == 2)
{
SimpleInterest();
}
if(m == 3)
{
FutureMoney();
}
if(m == 4)
{
Time();
}
if(m == 5)
{
Rate();
}
if(m == 6)
{
Manytimes();
}
}
while( m == 0);
}