calculate sales tax

J

Joe Estock

matt said:
After a lot of playing around here is what I not have:

#include <stdio.h>
#define STAX .0825

int main(){
double price;
printf("What is the price?\n");
scanf("%f", &price);
printf("%f\n", (double)price);

Why the unnecessary cast to a double when price is already declared as such?
price = price * STAX;
printf("The sales tax is: %.2f\n", price);

Use %lf as another poster in this thread suggested.
return 0;
}

When prompted for a price I put in 9.99 and here is what is returned:

What is the price?
9.99
521666.640505
The sales tax is: 43037.50

Not exactly what I expected.

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top