c++作业3

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x,y;
	cout<<"请输入x的值:";
	cin>>x;
	if(x>=10)y=1/(x+1);
	else if(6<=x&&x<10)y=sqrt(x+1);
	else if(2<=x&&x<6)y=x*x+1;
	else y=x;
	cout<<y<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int money,a,interest,sum=0;
	cout<<"欢迎使用利息计算器"<<"\n";
	cout<<"请输入存款金额:";
	cin>>money;
	cout<<"存款期限"<<"\n";
	cout<<"1.3个月"<<"\n"<<"2.6个月"<<"\n"<<"3.一年"<<"\n"<<"4.二年"<<"\n"<<"5.三年"<<"\n"<<"6.五年"<<"\n";
    cout<<"请输入存款期限的代号:";
    cin>>a;
	switch(a)
	{case 1:interest=money*0.031*0.25;
	cout<<interest;break;
	case 2:interest=money*0.033*0.5;
	cout<<interest<<endl;break;
    case 3:interest=money*0.035*1;
	cout<<interest<<endl;break;
	case 4:interest=money*0.044*2;
    cout<<interest<<endl;break;
	case 5:interest=money*0.05*3;
	cout<<interest<<endl;break;
	case 6:interest=money*0.055*5;
	cout<<interest<<endl;break;
	}
	sum=money+interest;
	cout<<"到期利息为:"<<interest<<" 元,本息合计共"<<sum<<" 元."<<"\n";
	cout<<"感谢您的使用,欢迎下次光临\n";
	return 0; 
}


#include<iostream>
using namespace std;
int main()
{
	int year,month;
	cout<<"请输入年份和月份:";
	cin>>year>>month;
	if(month==2)
	{
		if((year%4==0)&&(year%100!=0)||(year%400==0))
			cout<<"本月有29天"<<endl;
		else
			cout<<"本月有28天"<<endl;
	}
		else if(month==4||month==6||month==9||month==11)
			cout<<"本月有30天"<<endl;
		else
			cout<<"本月有31天"<<endl;
		return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值