根据上网时间t计算并输出上网费用cost,计算公式:
同时为了鼓励多上网,每月收费最多不超过300元。
#include<stdio.h>
int main()
{
int t,cost;
printf("上网费用cost=");
scanf("%d",&t);
if(t<10)
cost=30;
else if(t>=50&&t<=120)
cost=2.5*t;
else if(t>=10&&t<50)
cost=2.5*t;
else if(t>120)
putchar('\a');
printf("%d\n",cost);
return 0;
}