您的位置:首页 > 其它

用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;
}


 

 









心得体会:。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐