#include<iostream>
using namespace std;*
* Copyright (c) 2012, 烟台大学计算机学院
* All rights reserved.
* 作者:李全港* 完成日期:2012 年10月26日
* 版本号:v1.0
*
* 输入描述:按条件输入存款和存款类型
* 问题描述:学会使用switch语句
* 程序输出:利息和本息和
int main()
{
int a,b;
double c,d,e,f,g,h,i;
cout<<"欢迎使用利息计算器!"<<endl;
cout<<"存款类型:"<<endl;
cout<<"1.活期"<<endl;
cout<<"2.3个月"<<endl;
cout<<"3.6个月"<<endl;
cout<<"4.一年"<<endl;
cout<<"5.二年"<<endl;
cout<<"6.三年"<<endl;
cout<<"7.五年"<<endl;
cout<<"请输入存款类型的序号:"<<endl;
cin>>a;
cout<<"请输入存款金额"<<endl;
cin>>d;
if(a<=1&&a<=7)
{
switch(a)
cout<<"请输入存款天数:"<<endl;
cin>>f;
{
case 1:
h=f/360;
e=0.005;
break;
case 2;
h=f/360;
e=0.031;
break;
case 3;
h=f/360;
e=0.033;
break;
case 4;
h=f/360;
e=0.035;
break;
case 5;
h=f/360;
e=0.044;
break;
case 6;
h=f/360;
e=0.05;
break;
case 7;
h=f/360;
e=0.055;
break;
}
c=d*e*h;
i=c+d;
cout<<"利息金额为:"<<c<<"元,本息合计共"<<i<<"元。"<<endl;
}
else
cout<<"您输入的类型不正确!"<<endl;
cout<<"欢迎使用利息计算器!"<<endl;
return 0;
}
心得体会:笔记本出问题了,没法运行。