looks like a beginner program. You already seem to know how
to use scanf, so that should do for reading in the purchase
amount:
Code:
scanf ("%f", &fAmount);
here's a link to the FAQ on validation. this may be a bit complex
to look at for a beginner, but its manageable if you stick with it.
if you just want to check that the amount entered is not too big
or too small (i.e. negative), try an if statement like this:
Code:
if (fAmount < 0 || fAmount > 5000)
{
printf ("Input is out of range\n");
}
finally, you already know how to do the calculations, so remove
the selection part and the associated if statements. to calculate
the total sale price, just add the tax on like this:
Code:
printf("\nYour tax amount is: $%.2f and the total price is $%.2f\n", (fAmount * fTax1), (fAmount + (fAmount * fTax1)));
now to finish up, in your code you use getch (), which is defined
in the nonstandard header conio.h - you didn't include it in the
post. also, its a bit much including a header for only one function,
especially when the same effect can be achieved using getchar
from stdio.h, take a look at this
lastly, use indentation as it makes debugging code a little easier.
as already mentioned, you used the code tags wrong, the top
one should have been at the end of the code and vice versa
that should help a little i think