Hello guys,
I'm new here and hoping to get some kind of help with my code. This code is to calculate sales tax for specific store. I've got the most part of the code working, but I have to modify it so that it continues to loop until the user decides to exit the program.
I would appreciate any help and thanks in advance!
#include <stdio.h>
#include <stdlib.h>
main()
{
//Define the Variables and their Values
float fltDelMar = .0725f; //Defines Del Mar's tax percentage
float fltEncinitas = .075f; //Defines Encinitas' tax percentage
float fltLaJolla = .0775f; //Defines La Jolla's tax percentage
float fltAmount; //Defines the sale amount
char chrPercent = '\45'; //Defines a % sign for usage in the program
int ui; //Defines an integer to hold the scanf amount function from user input to be verfied
char storelocation; //Defines the storelocatoin character
//Displays information about the tax calculator program
printf("Kudler Fine Foods Tax Calculator\n");
printf("\nThis program will calculate the taxable amount based \non the inputed amount for the selected Kudler stores.\n");
printf("\nTax breakdown below:");
printf("\nDel Mar - 7.25%c tax rate", chrPercent);
printf("\nEncinitas - 7.5%c tax rate", chrPercent);
printf("\nLa Jolla - 7.75%c tax rate\n", chrPercent);
{
//Allows the user to enter an amount to be taxed
printf("\nPlease enter the purchase amount in dollars & cents, then press [ENTER]:$");
ui = scanf("%f",&fltAmount);
fflush(stdin);
if (ui <= 0)
{
printf("That is not a valid purchase amount.\n");
}
else
{
//Allows the user to select the store
printf("\nPlease select the store to compute tax:\n");
printf("1) DelMar \n2) Encinitas \n3) La Jolla \n");
printf("Select 1, 2, 3: ");
//Calculates the tax rates as well as totals the transaction
scanf("%c",&storelocation);
fgetc(stdin);
printf("%c",&storelocation);
if (storelocation == '1')
{
printf("\nDel Mar: Tax= $%.2f, Total= $%.2f\n", fltDelMar * fltAmount, (fltDelMar * fltAmount) + fltAmount);
}
else if (storelocation == '2')
{
printf("\nEncinitas: Tax= $%.2f, Total= $%.2f\n", fltEncinitas * fltAmount, (fltEncinitas * fltAmount) + fltAmount);
}
else if (storelocation == '3')
{
printf("\nLa Jolla: Tax= $%.2f, Total= $%.2f\n", fltLaJolla * fltAmount, (fltLaJolla * fltAmount) + fltAmount);
}
else
{
printf("Entry not acceptable, please choose another selection.");
}
}
//Requires the user to press [ENTER] to exit the program
printf("\nThank you for using the tax calculator!\nHave a nice day!!!\n");
printf("\nPress [ENTER] to exit the program...");
getchar();
}
}