#include<stdio.h>
int main(void)
{
//销售佣金计算器
unsigned int x=200;//定义x为底薪
float sum;//定义sum为销售总额
float salary;//定义salary为薪水
printf("Enter sales in dollars (-1 to end):");
scanf("%f",&sum);
while(sum!=-1)
{
salary=0.09*sum+x;
printf("Salary is : $ %0.2f\n",salary);
printf("\nEnter sales in dollars (-1 to end):");
scanf("%f",&sum);
}
}
销售佣金计算器:某大型化学药品公司以销售员的佣金为基础来支付其工资。销售员每周的工资是¥200的底薪,加上该周销售额的9%。请编写这样一个程序:输入每位销售员上周的销售总额,计算并显示他们的收入。每次只处理一名销售员的数据。
运算结果:
利息计算器:贷款的利息公式:利息=本金*利率*天数/365
请开发一个程序:读入若干比贷款的本金、利率和借贷天数,使用上面的公式计算并显示每笔贷款的利息。
#include<stdio.h>
int main(void)
{
//利息计算器
float principal;
float rate;
int days;
float interest;
printf("Enter loan principal (-1 to end): ");
scanf("%f",&principal);
while(principal!=-1)
{
printf("Enter interest rate: ");
scanf("%f",&rate);
printf("Enter term of the loan in days: ");
scanf("%d",&days);
interest=principal*rate*days/365;
printf("The interest charge is $ %.2f\n\n",interest);
printf("Enter loan principal (-1 to end): ");
scanf("%f",&principal);
}
}
利息计算器运算结果: