Remove the single quotes in the switch case.
I have modified your program into the following.
Try with that.
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);
break;
case 2: printf("Encinitas Sales Tax: $%.2d\n", totaltax2);
printf("Encinitas Total Purchase: $%.2d\n\n", totalpurchase2);
break;
case 3: printf("La Jolla Sales Tax: $%.2d\n", totaltax3);
printf("La Jolla Total Purchase: $%.2d\n\n", totalpurchase3);
break;
default:
printf("Invalid option\n");
}//end of switch
//used to keep console window open
system("Pause");
return 0;
}//end of main function
storelocation is a integer not a character.
So 1 and '1' is not equal.
For more details refer the following program.
Code:
#include<stdio.h>
main()
{
if(1=='1')
printf("true\n");
else
printf("False\n");
}
.