Skip to content

Instantly share code, notes, and snippets.

@lazuee
Created January 19, 2023 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazuee/426c41fc99954ba58d6a77aceab096c4 to your computer and use it in GitHub Desktop.
Save lazuee/426c41fc99954ba58d6a77aceab096c4 to your computer and use it in GitHub Desktop.
Calculating Sales Tax on a Purchase in C++
#include <cstdio>
int main() {
double purchase, tax_rate, total_bill;
char county;
printf("AMOUNT OF PURCHASE? ");
scanf("%lf", &purchase);
printf("COUNTY? ");
scanf(" %c", &county);
if (county == 'A') {
tax_rate = 0.07;
} else {
tax_rate = 0.06;
}
total_bill = purchase + (purchase * tax_rate);
printf("TOTAL BILL: %.2lf\n", total_bill);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment