Ok Guy's,
My instructor gave me this feedback: "Your totals are fine, but your taxes
are off by a factor of 100. Your error checking is effective, but should
terminate the program rather than continuing to show taxes on a $0 purchase.
I honestly have no clue what to do. Any suggestions would be appreciated.
Code:
/*Kudler Fine Foods Tax calculator*/
//Description: A C program by Max Maxwell that displays the sales tax amount for each of the store locations based on taxable
//amounts entered by the user.
#include<stdio.h>
#include <stdlib.h>
int main (void)
{
//declaring variables
float Purchase_Amount = 0.0; //Variable for the purchase amount initialized at 0
float DelMar_TaxRate = 7.25; //Del Mar Tax Rate
float Encinitas_TaxRate = 7.50; //Encinitas Tax Rate
float LaJolla_TaxRate = 7.75; //La Jolla Tax Rate
//Welcome Screen
printf("Kudler Fine Foods Tax Calculation Program\n");
printf("\nPlease Enter Your Purchase Amount: ");
if(scanf_s("%f", &Purchase_Amount) !=1) //Error Check and Message
{
printf(" That was an Invalid Purchase Amount. Please try again. Example 99.99, enter Zero to exit\n");
}
//Calculations For each location//
//TotalAmount = PurchaseAmount * DelMarTaxRate / 100.00 + PurchaseAmount
printf("\nThe Del Mar Tax Rate of 7.25%% adds $%2.2f", DelMar_TaxRate * Purchase_Amount);
printf(" for a \ntotal of ---------> $%.2f.\n", ((DelMar_TaxRate / 100) * Purchase_Amount) + Purchase_Amount);
printf("\nThe Encinitas Tax Rate of 7.50%% adds $%2.2f", Encinitas_TaxRate * Purchase_Amount);
printf(" for a \ntotal of ---------> $%.2f.\n", ((Encinitas_TaxRate / 100) * Purchase_Amount) + Purchase_Amount);
printf("\nThe La Jolla Tax Rate of 7.75%% adds $%2.2f", LaJolla_TaxRate * Purchase_Amount);
printf(" for a \ntotal of ---------> $%.2f.\n", ((LaJolla_TaxRate / 100) * Purchase_Amount) + Purchase_Amount);
printf("\n\n\tThank you and have a nice day!\n\n");
return 0;
}