# Thread: can someone check this code

1. ## can someone check this code

code:

Code:
```#include <stdio.h>
#include <math.h>
/**********************************************************************************************************/
Sales Tax
/**********************************************************************************************************/
/*                                                                                 Developed by:  Glenn Wiggins                                                                              */
/*                                                                                                                                                                                                                 */
/**********************************************************************************************************/
/*	This program will compute a 6% sale tax on a purchase.  The program user is to input the total amount of the                   */
/*     purchase.  The program is to return the original amount of the purchase, the tax, and the total of the two.                                    */
/**********************************************************************************************************/
/*                                                                                      Variables used:                                                                                                  */
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*                                                            Purchase_amount = Total amount of purchase                                                                          */
/*                                                                         Sale_tax = Total amount of sale tax                                                                              */
/*                                                            Total_sum = Total amount of purchase and total amount of sale tax added together                */
/**********************************************************************************************************/
/*                                                                                      Constants used:                                                                                                 */
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*                                                                          I = .06   (Sale tax percentage)                                                                                       */
/**********************************************************************************************************/

int main(void )

{
/* Declarations block */

float  Purchase_amount;		/* Amount purchased.		*/
float  Sale_tax;			/*Amount of sales tax.	*/
float  Total_sum;			/*Total amount owed.		*/
float I = .06;			/* Precent sale tax.		*/

/*  Explain the program to the user.  */

puts () ;
puts (This program will compute a 6% sales tax on a purchase.) ;
puts (It will return the original amount of the purchase, the tax, ) ;
puts (and the total of the two.) ;
puts () ;

puts (You on ly need to enter the total amount purchased.) ;

/* Get total amount purchase from user.  */

puts () ;
printf (Enter the total amount purchase  =>  ) ;
scanf ( %f,  &   purchase_amount) ;

/*  Do computations.  */

Sale_tax = I * Purchase_amount ;```

2. ## i am confuse

i am confuse about the rest of the calculation and how to display the total

3. Compute the tax in simple maths terms... then printf the result with printf().

Something like
>printf ("Sale Amount: %f plus %f tax is %f\n", SaleAmount, Tax, SaleAmount+Tax);

There's somethings you'll need to learn about formatting of the output, but I'll let you find that out for yourself

Also, have a read of this.

4. Likely a bug filled masterpiece, but perhaps it *might* help.

Code:
```#include <stdio.h>

int main(void)
{
const float salesTax = 0.06;
float prices[3] = { 3.99, 2.75, 1.35 };
float subTotal, total;
int selection;

subTotal = 0.0;
total = 0.0;

printf("1> wrench \$3.99\n");
printf("2> socket \$2.75\n");
printf("3> wood   \$1.35\n");
printf("\n--> ");

scanf("%d", &selection);

subTotal = prices[selection - 1];

total = (subTotal * salesTax) + subTotal;

printf("\nFor item purchased, you owe %.2f\n", total);

return 0;
}```
Of course you'd have to check it for data input that is out of range.

5. In the future please use code tags when posting code. I added them for you this time. People are MUCH more likely to help you if you use them.

Info on code tags may be found here: