实验2-2-8 阶梯电价 (15 分)
作者:互联网
实验2-2-8 阶梯电价 (15 分)
#include <stdio.h>
int main()
{
float v;
scanf("%f",&v);
float cost;
if (v<=50) {
cost = v*0.53;
}
else if (v>50) {
cost = 50*0.53 + (v-50)*(0.53+0.05);
}
if (v<0) {
printf("Invalid Value!");
}
else {
printf("cost = %.2f",cost);
}
return 0;
}
标签:15,电价,float,50,阶梯,cost,0.53,else 来源: https://blog.csdn.net/Drek_Hu/article/details/113617894