/* This program reads incomes from the file incomes.dat until end-of-file and writes the taxes due to the file out.dat. Income under 6000 greenbacks is taxed at 30 percent, and income greater than or equal to 6000 greenbacks is taxed at 60 percent. We assume that the income is an integer. The tax is written as an integer. */ #include main() { int income, tax; FILE *fin, *fout; fin = fopen( "incomes.dat", "r" ); fout = fopen( "out.dat", "w" ); while ( fscanf( fin, "%d", &income ) != EOF ) { fprintf( fout, "Income = %d greenbacks\n", income ); if ( income < 6000 ) tax = 0.3 * income; else tax = 0.6 * income; fprintf( fout, "Tax = %d greenbacks\n", tax ); } }