1 import java.util.Scanner;
 2
 3
 4 public class exercise {
 5
 6     public static void main(String[] args) {
 7         int select;
 8         do{
 9         System.out.println("请问您想要进行单利计算还是复利计算:1.单利 2.复利");
10         Scanner keyin0=new Scanner(System.in);
11         select=keyin0.nextInt();
12         }while(select!=1&&select!=2);
13         System.out.println("请输入您想要存储的金额数量:");
14         Scanner keyin1=new Scanner(System.in);
15         double originalMoney=keyin1.nextDouble();
16         System.out.println("请输入您想要存储金额的时间(年):");
17         Scanner keyin2=new Scanner(System.in);
18         int year=keyin2.nextInt();
19         System.out.println("请输入您想要设计的年利率:");
20         Scanner keyin3=new Scanner(System.in);
21         double rate=keyin3.nextDouble();
22         double sumValue=originalMoney;
23         if(select==1)
24         {
25             double singleValue=originalMoney*(1+rate*year);
26             System.out.println("存入第"+year+"年后的存款总额为:"+singleValue);
27             do{
28                 System.out.println("请问您想要计算本金问题吗:1.需要 2.不需要");
29                 select=new Scanner(System.in).nextInt();
30                 }while(select!=1&&select!=2);
31             if(select==1){
32                 System.out.println("请输入您想要筹到的金额:");
33                 singleValue=new Scanner(System.in).nextDouble();
34                 System.out.println("请输入您想要存储金额的时间(年):");
35                 year=new Scanner(System.in).nextInt();
36                 System.out.println("请输入您想要设计的年利率:");
37                 rate=new Scanner(System.in).nextDouble();
38                 originalMoney=singleValue/(1+rate*year);
39                 System.out.println("需要本金"+originalMoney+"元");
40             }
41         }
42         else
43         {
44         for(int i = 1 ; i<=year; i++){
45                sumValue= (1+ rate)*sumValue;
46
47         }
48         System.out.println("存入第"+year+"年后的存款总额为:"+sumValue);
49         do{
50             System.out.println("请问您想要计算本金问题吗:1.需要 2.不需要");
51             select=new Scanner(System.in).nextInt();
52             }while(select!=1&&select!=2);
53         if(select==1){
54             System.out.println("请输入您想要筹到的金额:");
55             sumValue=new Scanner(System.in).nextDouble();
56             System.out.println("请输入您想要存储金额的时间(年):");
57             year=new Scanner(System.in).nextInt();
58             System.out.println("请输入您想要设计的年利率:");
59             rate=new Scanner(System.in).nextDouble();
60             for(int i = 1 ; i<=year; i++){
61                    sumValue= sumValue/(1+ rate);
62
63             }
64             originalMoney=sumValue;
65             System.out.println("需要本金"+originalMoney+"元");
66         }
67         do{
68             System.out.println("请问您想要计算时间问题吗:1.需要 2.不需要");
69             select=new Scanner(System.in).nextInt();
70             }while(select!=1&&select!=2);
71         if(select==1){
72             System.out.println("请输入您想要存储的金额数量:");
73             originalMoney=new Scanner(System.in).nextDouble();
74             System.out.println("请输入到期后您想要获取的金额:");
75             sumValue=new Scanner(System.in).nextInt();
76             System.out.println("请输入您想要设计的年利率:");
77             rate=new Scanner(System.in).nextDouble();
78             year=1;
79             for(; sumValue>originalMoney;year++){
80                 originalMoney= originalMoney*(1+ rate);
81
82             }
83             year--;
84             System.out.println("需要"+year+"年时间");
85         }
86
87
88
89         }
90
91     }
92
93 }

              

转载于:https://www.cnblogs.com/57rongjielong/p/5269634.html

单利计算与复利计算程序相关推荐

  1. 工程经济学(单利计算与复利计算)

    考点一.单利计算和复利计算的区别 单利计算. 第一年:100万(本金)|  1005%=5万(利息) 第二年(利息):1005%=5万 第三年(利息):   1005%=5万 总结,单利计算利息的计费 ...

  2. 计算复利java代码_【软件工程】复利计算程序单元测试

    这次更新我将Money类中各种计算模式的算法封装到了Arithmetic算法类中,以便代码复用及代码测试.但是由于单元测试无法测试private修饰的方法,所以我将Arithmetic中的方法访问修饰 ...

  3. 复利单利计算0318

    #include<stdio.h> #include<math.h> //复利 void fuli(){int n,k;double F,P;float i;printf(&q ...

  4. 0316复利和单利计算更新4

    1 #include<stdio.h> 2 #include<math.h> 3 int year,n; 4 double p,q,F=0.0; 5 void innit() ...

  5. 复利单利计算的源代码

    1.客户说:帮我开发一个复利计算软件. 客户提出: 2.如果按照单利计算,本息又是多少呢? 3.假如30年之后要筹措到300万元的养老金,平均的年回报率是3%,那么,现在必须投入的本金是多少呢? 客户 ...

  6. 复利单利计算的功能解释

    复利单利计算的功能解释: 开发语言:C语言 开发工具:VC++6.0 功能: 1 菜单: 主要通过printf输出,让客户可以方便输入. 2 本利和和本金求解: 种类1,2,3都是对本利和的求解,种类 ...

  7. matlab计算连续复利,Code 2-1 单利、离散复利与连续复利的对比

    %Code 2-1 单利.离散复利与连续复利的对比 %------------------------------------------------------------------------- ...

  8. python计算存款复利计算器_GitHub - dxcv/Options-Calculator: 期权价格计算器——金融工程第二次展示...

    Options Calculator 这是一个全能的期权计算器,涵盖 BS法,蒙特卡洛法,二叉数法,能够对看涨期权,看跌期权,欧式期权,美式期权,有股利期权,无股利期权进行定价,并附带GUI客户端. ...

  9. 计算收益复利的小例子

    一个计算收益复利的小例子, 用c语言简单编程, 如 test 30 20 40: 30以万为单位,20是年收益百分比,40是年数. #include <stdio.h> #include ...

  10. python计算连续复利_复利的Python程序

    python计算连续复利 Given principle amount, rate and time and we have to find the compound interest in Pyth ...

最新文章

  1. springboot中radis配置和使用【进阶二】
  2. android @id和@+id的区别
  3. Java编程讲义之Eclipse开发工具
  4. WebAPI(part4)--操作元素
  5. python中type用法_Python中type的用法
  6. HDU 5773 The All-purpose Zero(O(nlgn)求LIS)
  7. BZOJ1862: [Zjoi2006]GameZ游戏排名系统
  8. Fragstats|单一土地利用类型景观格局指数
  9. OpenGL ES 3.1 Android扩展包介绍
  10. 电子表整点报时怎么取消_双11红包雨入口在哪 双十一秒杀券怎么抢
  11. InnoDB行格式(COMPACT,redundant)对比
  12. 实时汇率转换小程序(c++爬虫)
  13. FC炸弹人 java源码下载
  14. 旁注、目录越权、跨库、CDN绕过
  15. scrapy爬虫实例:凤凰网
  16. 装配一台计算机有哪些安全注意事项,挤出机注意事项
  17. 自然语言词向量模型:Glove和Bert
  18. python基础教学习题_python基础|数据类型练习题
  19. C语言编程-----求s=a+aa+aaa+aaaa+aa...a的值
  20. java飞鸽传书_java简单版飞鸽传书

热门文章

  1. 遗落在时光里的静态链表(线性表的静态存储)---C语言版
  2. 【equals与==比较】String的两种拼接
  3. PAT (Basic Level) Practice1006 换个格式输出整数
  4. I/O设备与主机的联系方式
  5. java 哈希表入门
  6. SparkStreaming窗口入门
  7. SparkStreaming读取Hdfs文件完成wordCount
  8. Linux终端下输出二维码
  9. Dev Express 安装
  10. Xbox One 游戏欣赏: 麦克斯-兄弟魔咒