用if-else语句编写利息计算器(第九周上机任务)
2012-10-26 13:26
330 查看
/* * Copyright (c) 2011, 烟台大学计算机学院 * All rights reserved. * 文件名称:test.cpp * 作 者:樊露露 * 完成日期:2012 年 10 月 25日 * 版 本 号:v1.0 * * 输入描述:无 * 问题描述:输入存款金额并选择存款种类,计算出利息 * 程序输出:利息和本息 * 问题分析:略 * 算法设计:略 */ #include<iostream> using namespace std; int main() { double lx,je,cq,bx; int x,y; cout<<"请输入存款类型:1.活期,2.死期.:"; cin>>x; if(x>=3) cout<<"选择存款类型错误!请重新选择."<<endl; else { cout<<"请输入存款金额(元):"; cin>>je; if(x==1) { cout<<"请输入存款期限:"; cin>>cq; lx=je*0.005*cq/360; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } else if(x==2) { cout<<"1. 3个月"<<endl; cout<<"2. 6个月"<<endl; cout<<"3. 一年"<<endl; cout<<"4. 二年"<<endl; cout<<"5. 三年"<<endl; cout<<"6. 五年"<<endl; cout<<"请您输入存款代号(1-6):"; cin>>y; if(y==1) { lx=je*0.031*3/12; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y==2) { lx=je*0.033*6/12; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y==3) { lx=je*0.035*1; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y==4) { lx=je*0.044*2; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y==5) { lx=je*0.05*3; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y==6) { lx=je*0.055*5; bx=lx+je; cout<<"到期利息为:"<<lx<<"元,本息合计共:"<<bx<<"元。"<<endl; cout<<"感谢您的使用,欢迎下次光临。"; } if(y>=7) cout<<"选择存款类型错误!请重新选择."<<endl; } } return 0; }
心得体会:。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
相关文章推荐
- 第九周上机任务(用if-else语句求解分段函数)
- 第九周项目1-用if,else语句计算函数值
- 编写程序,用if else语句根据姓名查询teaching数据库中学生的基本信息和选课信息,学生姓名通过变量输入。不存在则输出提示信息
- 编写一个Java程序,用if-else语句判断某年份是否为闰年。
- 用if else语句编写程序读取输入,直到‘#’,用一个感叹号代替原有的句号,用两个感叹号代替原有的感叹号
- shell脚本之while for if 语句和编写计划任务
- 利用if else 语句编写程序读取输入,直到#。用一个感叹号代替每个句号,将原有的每个感叹号用两个感叹号替换,最后 报告进行了多少次替换。
- 第九周上机任务项目3:利息计算器
- 编写一个计算某个月份的天数程序,请用if-else条件语句实现。要求根据用户输入的月份,判断出月份所包含的天数。
- 利用if else语句编写程序读取输入,直到#, 用一个感叹号代替每个句号,将原有的每个感叹号用两个感叹号代替,最后报告进行了多少次替代。
- 第九周上机任务--利息计算器
- 利息计算器(第九周上机任务3)。
- C primer plus 第七章 练习4: 利用if else语句编写程序读取输入,直到#, 用一个感叹号代替每个句号,将原有的每个感叹号用两个感叹号代替,最后报告进行了多少次替代。
- 编写程序将一个百分制成绩转换为五分制成绩。转换规则: 大于等于90分为A; 小于90且大于等于80为B; 小于80且大于等于70为C; 小于70且大于等于60为D; 小于60为E。用if-else语句
- 第九周项目2-用if-else语句求应缴税和税后收入
- State模式(状态模式)消除烦琐的if..else语句
- 练习2-10 重新编写将大写字母转换为小写字母的函数lower,并用条件表达式替代其中的if-else结构。
- 1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- 题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
- 求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)