Use the following schedule to calculate the monthly income of a salesperson. Acc
ID: 3640908 • Letter: U
Question
Use the following schedule to calculate the monthly income of a salesperson. Accept user input for the value of the monthly sales. Using if-else to calculate income. Save the value of the income to a text file named sales income.txt. Open the file in append mode after the first successful attempt and observe the change.Monthly Sales Income
Greater than or equal to $50,000 $375 plus 16% of sales
Less than $50,000 but greater than or $350 plus 14% of sales
equal to $40,000
Less than $40,000 but greater than $325 plus 12% of sales
or equal to $30,000
Less than $30,000 but greater $300 plus 9% of sales
than or equal to $20,000
Less than $20,000 but greater $250 plus 5% of sales
than or equal to $10,000
Less than $10,000 $200 plus 3% of sales
Explanation / Answer
Please rate...
#include<stdio.h>
void main()
{
FILE *fp;
float monthly_sales,income;
printf("Enter the amount of monthly sales: ");
scanf("%f",&monthly_sales);
if(monthly_sales>=50000)income=375+(0.16*monthly_sales);
else if(monthly_sales<50000.0 && monthly_sales>=40000.0)income=350.0+(0.14*monthly_sales);
else if(monthly_sales<40000.0 && monthly_sales>=30000.0)income=325.0+(0.12*monthly_sales);
else if(monthly_sales<30000.0 && monthly_sales>=20000.0)income=300.0+(0.09*monthly_sales);
else if(monthly_sales<20000.0 && monthly_sales>=10000.0)income=250.0+(0.05*monthly_sales);
else if(monthly_sales<10000.0)income=200.0+(0.03*monthly_sales);
fp = fopen("income.txt", "a");
fprintf(fp," %f",income);
fclose(fp);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.