Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Programming The Internal Revenue Service (IRS) allows tax payers who itemize d

ID: 668100 • Letter: C

Question

C Programming

The Internal Revenue Service (IRS) allows tax payers who itemize deductions to writeoff mileage driven for various purposes. During the 2012 tax year, the following rates have been set:

• 55.5 cents per mile for business miles driven

• 23 cents per mile driven for medical or moving purposes

• 14 cents per mile driven in service of charitable organizations

Write a program to determine a user’s total deduction for mileage driven. Your program will prompt the user for the total mileage driven in 2012 for each category. It will add up the total deduction and report it to the user. Note: the user should be able to enter fractional miles, however you should report only whole cents (the IRS allows you to round up only if the fractional cent is greater than one half).

An example of this interaction:

MILEAGE DEDUCTION CALCULATOR

Enter total business miles driven: 1024.25

Enter total medical or moving miles driven: 100.0

Enter total charitable miles driven: 0

Your total tax deduction for 2012: $591.46

Be sure that you format your output in a sensible manner and echo an error message for invalid odometer readings.

Explanation / Answer

#include<stdio.h>
#include<conio.h>

void main()
{
   float bm,mm,cm,tbm,tmm,tcm,tot;

   clrscr();

   printf("MILEAGE DUDUCTION CALCULATOR ")

   printf("Enter total business miles driven: ");
   scanf("%f",&bm);

   printf("Enter total medical or moving miles driven: ");
   scanf("%f",&mm);

   printf("Enter total charitable miles driven: ");
   scanf("%f",&cm);

   if(bm<0 || mm<0 || cm<0)
   {
       printf("Wrong entry...Pl. try again);
       return;
   }
   else
   {  
       tot=(bm*0.55)+(mm*0.23)+(cm*0.14);

       printf("Your total tax deduction for 2012: $%f",tot);
   }
   getch();
}