I'm trying to modify the program. So, the user inputs the purchase
amount and the program checks the users input for validity. HELP I need today!!
Code:
/*
Program: Kudler Tax Calculation Program
SR-kf-008
Date: August 11, 2006
Author: Douglas Niemczynski
*/
#include <stdio.h>
void main()
{
float fDelMar = 0.0725f; // tax for Del Mar
float fEncinitas = 0.0750f; // tax for Encinitas
float fLaJolla = 0.0775f; // tax for La Jolla
float fPurchaseAmount = 0.0f; // amount of purchase
float fTax = 0.0f; // taxes
float fTotal = 0.0f;
int iStoreChoice = 0; // menu selection
// print menu
printf("\n1 - Del Mar");
printf("\n2 - Encinitas");
printf("\n3 - La Jolla");
printf ("\nSelect city number 1, 2, or 3\n");
printf("\nEnter your selection: ");
scanf("%d", &iStoreChoice);
printf("\n\nEnter Purchase Amount: ");
scanf("%f", &fPurchaseAmount);
// apply taxes for purchase ammount
switch (iStoreChoice)
{
case 1:
fTax = fPurchaseAmount * fDelMar;
break;
case 2:
fTax = fPurchaseAmount * fEncinitas;
break;
case 3:
fTax = fPurchaseAmount * fLaJolla;
break;
}
fTotal = fPurchaseAmount + fTax;
// print out
printf("Purchase Price:\t%.2f", fPurchaseAmount);
printf("\nTotal price after taxes of (%.2f) is %.2f\n", fTax, fTotal);
printf("\nPress ENTER to Quit\n");
fflush(stdin);
getchar();
}