See if this hatchet job will be of any use. It's late and I'm tired, so things were cutback from your original post. Let's just hope the cutbacks weren't part of the programs purpose
Code:
#include <stdio.h>
#include <ctype.h>
void showResults(float, double, double);
double calcDiscount(char, float);
int main(void)
{
float initialAmount;
double discountAmount, finalCost;
char discountCode;
printf("Discount code A = 5%%.\n");
printf("Discount code B = 8%%.\n");
printf("Discount code C = 12%%.\n");
printf("\nInput the customer's discount code: ");
scanf("%c", &discountCode);
printf("Input the customer's invoice amount: ");
scanf("%f", &initialAmount);
discountAmount = calcDiscount(discountCode, initialAmount);
finalCost = initialAmount - discountAmount;
showResults(initialAmount, discountAmount, finalCost);
return 0;
}
double calcDiscount(char code, float amount)
{
double total;
switch(toupper(code))
{
case 'A': total = 0.05 * amount;
break;
case 'B': total = 0.08 * amount;
break;
case 'C': total = 0.12 * amount;
break;
default: printf("\nThere is no such option for %c\n", code);
total = 0.0;
break;
};
return total;
}
void showResults(float amount1, double amount2, double amount3)
{
printf("\nThe invoice charges are as follows:\n");
printf("\nInitial Invoice: %.2f", amount1);
printf("\nDiscount Amount: %.2f", amount2);
printf("\n--------------------------");
printf("\nFinal Cost: %.2f", amount3);
}
Good luck.