Question regarding addition:

This is a discussion on Question regarding addition: within the C Programming forums, part of the General Programming Boards category; Here is my current code for a calculator; I'm struggling in getting it to display the fourth category total amount ...

1. Question regarding addition:

Here is my current code for a calculator; I'm struggling in getting it to display the fourth category total amount which would be sale amount + tax sales amount. Any hints here would be appreciated.

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

#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

float user_input(){
float amount;
printf("Please input sales amount\n");
scanf("%f", &amount);
return amount;
}
int main(){
float sales = 125.00;
sales = user_input();
if (sales < 0.00) {
printf("A sale cannot be negative. Please try again");
exit(-1);
}

printf("Tax Calculator for Kudler Fine Foods\n\n\n");

printf("Store Location\tSales Amount\tTax Percentage\tTax Amount\tTax Amount\tTotal Amount\n");
printf("Del Mar Store\t\$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, DelMar, sales*DelMar/100);
printf("Encinitas Store\t\$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, Encinitas, sales*Encinitas/100);
printf("La Jolla Store\t\$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, LaJolla, sales*LaJolla/100);
printf("                        Press the enter key to exit the calculator\n");
getch();

return 0;

}```

2. If sale amount is "sales" and sales tax is "sales*DelMar/100", then sales + sales tax would be "sales + sales*DelMar/100".

3. Simple enough. Don't know why but I was trying to get it done in a more complicated way. Thanks!

Popular pages Recent additions