help with a switch and a loop
I am writing this program fro a class and it will compile in bloodshed, but will not give me the total price that I am trying to get to. The steps are to pick a location, enter a purchase amount and it is suppose to give you the tax and total amounts, but it stops after the purchase amount is entered. Can anyone see my error?
Code:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
//declare sales tax rates and initialize variables
float purchase = 0.0;
float delmar_rate = 0.0725;
float encinitas_rate = 0.075;
float lajolla_rate = 0.0775;
float totaltax1= 0;
float totaltax2= 0;
float totaltax3 = 0;
float totalpurchase1 = 0;
float totalpurchase2 = 0;
float totalpurchase3 = 0;
int storelocation = 0;
//enter input items
printf("Kudler Fine Foods Sales Tax\n");
printf("\n Please Select:\n 1 - Del Mar\n 2 - Encinitas\n 3 - La Jolla\n");
printf("\nPlease select a store (1-3): ");
scanf("%d", &storelocation);
printf("\nEnter Purchase Total: $");
do
{
scanf("%f",&purchase);
//Display error message to user.
if (purchase <= 0)
{
printf("Error: purchase must be greater than 0\n");
printf("\nEnter Purchase Total: $");
} //if PurchaseAmount <=0)
} while (purchase <= 0);
//Perform the Calculations.
totaltax1 = purchase * delmar_rate;
totaltax2 = purchase * encinitas_rate;
totaltax3 = purchase * lajolla_rate;
totalpurchase1 = totaltax1 + purchase;
totalpurchase2 = totaltax2 + purchase;
totalpurchase3 = totaltax3 + purchase;
//print tax amount and total sale
switch(storelocation){
case '1': printf("\nDel Mar Sales Tax: $%.2d\n", totaltax1);
printf("Del Mar Total Purchase: $%.2d\n\n", totalpurchase1);
case '2': printf("Encinitas Sales Tax: $%.2d\n", totaltax2);
printf("Encinitas Total Purchase: $%.2d\n\n", totalpurchase2);
case '3': printf("La Jolla Sales Tax: $%.2d\n", totaltax3);
printf("La Jolla Total Purchase: $%.2d\n\n", totalpurchase3);
}//end of switch
//used to keep console window open
system("Pause");
return 0;
}//end of main function