第9周 利息计算系统!

时间:2023-01-08 16:57:24
#include<iostream>
using namespace std; 
int main()  
{  
	int  type, days; 
	double money, period, rate, interest; //“period”?往下看就了然了!
	cout <<endl;
	cout << "  ========欢迎使用利息计算系统!========= " << endl << endl;
	cout << "        请选择下列业务的相应代号" <<endl;
    cout << "  =======================================" << endl;
	cout << "                1.活期储蓄" << endl;
	cout << "                2.三个月" << endl;
	cout << "                3.六个月" << endl;
	cout << "                4.一年" << endl;
	cout << "                5.二年" << endl;
	cout << "                6.三年" << endl;
	cout << "                7.五年" << endl;
	cout << "  =======================================" << endl << endl;
	cout <<"  您选择的业务代号为:";
    cin >> type ;
    if (type>=1 && type <=7) 
	{
	   switch(type)
	   {
	          case 1: 
				  cout << "  请输入存款天数:";
                  cin >> days;
                  rate = 0.005; 
                  period = days /360.0; //豁然开朗!此处的“period”用得相当高明啊。解决了我很苦恼的一个问题。跪了!                  
                  break;  
	          case 2: 
				  rate = 0.031;
				  period = 0.25;
				  break;
	          case 3: 
				  rate = 0.033;
                  period = 0.50;
				  break;
	          case 4: 
				  rate = 0.035;
				  period = 1.0;
				  break;
	          case 5: 
				  rate = 0.044;
				  period = 2.0;
				  break;
	          case 6: 
				  rate = 0.050;
				  period = 3.0;
				  break;
	          case 7: 
				  rate = 0.055; 
		          period = 5.0;
				  break;
	   }
       cout << "  请输入您的存款金额:¥";
	   cin >> money ;
       interest = money * rate * period;
	   cout << "  您的利息为:¥"<< interest << "本息合计¥" << interest+money <<endl;
	   cout << "  谢谢您的使用,欢迎下次光临!"<<endl;
	   }
    else  
        cout << "  你选择的业务代号有误,请确认后再次输入。"<<endl; //其实再输入就木有了。。  
	return 0;  
}  

 

运行结果:

第9周 利息计算系统!

第9周 利息计算系统! 

第9周 利息计算系统!

 

心得体会:

 

        说实话,编程序的这个把月以来,以这次编的最有成就感。