Respuesta :
Answer:
#include<stdio.h>
void main()
{
// using file pointer to print output to txt file
FILE *fptr;
float assessedValue, taxableAmount, taxRate = 1.05, propertyTax;
/* open for writing */
fptr = fopen("output.txt", "w");
if (fptr == NULL)
{
printf("File does not exists \n");
return;
}
// prompting user to enter assessed value and storing it in assessedValue variable
printf("Enter the Assessed Value of property : ");
scanf("%f", &assessedValue);
//writing assessed value to output.txt file using fprintf file i/o function
fprintf(fptr, "AssessedValue : $ %.2f\n", assessedValue);
//calculating taxableAmount based on given condition in the question
taxableAmount = (assessedValue * 0.92);
//writing taxable Amount to output.txt file using fprintf file i/o function
fprintf(fptr, "TaxableAmount: $ %.2f\n", taxableAmount);
//writing tax Rate to output.txt file using fprintf file i/o function
fprintf(fptr, "Tax Rate for each $100.00: $ %.2f\n", taxRate);
//calculating propertyTax based on given condition in the question
propertyTax = ((taxableAmount/100)*taxRate);
//writing property Tax Amount to output.txt file using fprintf file i/o function
fprintf(fptr, "propertyTax: $ %.2f\n", propertyTax);
//closing file using fclose function
fclose(fptr);
}
Explanation :
I used Turbo C compiler to compile and run the C program. The below program compiles and at the run time, automatically, prints output to a file called output.txt.
When you compile the program, remember to check the BIN folder in Turbo c folder of C drive where your turbo c has been installed.
Output:
Assessed value: $200000
Taxable amount: $184000
Tax Rate for each $100.00: $1.05