Write a C program that: 1. Accepts the total purchase amount, customer type, and season from the user. 2. Uses nested if-else statements to calculate and display the final amount after applying the discount.

Here is a C Program for Customer and Day Based Shop Management Program 


#include <stdio.h>


int main() {
    char name[20];
    float totalPurchase, finalAmount;
    int customerType;
    int season;      
    float discount = 0.0;
    printf("Enter Your name: ");
    scanf("%s", name);
    printf("_________________________________________________________");
   
    printf("\nEnter the total purchase amount that you Purchased: Rs.");
    scanf("%f", &totalPurchase);
   
    printf("\nEnter customer type (1 for Regular, 2 for Premium, 3 for VIP): ");
    scanf("%d", &customerType);
   
    printf("Enter season (1 for Normal, 2 for Holiday): ");
    scanf("%d", &season);

   
    if (customerType == 1) {
        if (season == 1) {
            discount = 0.05;
        } else if (season == 2) {
            discount = 0.10;  
        }
    } else if (customerType == 2) {
        if (season == 1) {
            discount = 0.10;
        } else if (season == 2) {
            discount = 0.15;  
        }
    } else if (customerType == 3) {
        if (season == 1) {
            discount = 0.15;
        } else if (season == 2) {
            discount = 0.20;
        }
    } else {
        printf("Invalid customer type.\n");
        return 1;
    }
   
   
    if (totalPurchase > 1000) {
        discount += 0.05; // Additional 5% discount
    }
   
   
    finalAmount = totalPurchase * (1 - discount);
        printf("Discount= %0.2f", totalPurchase - finalAmount);
   
    printf("\nDear %s, ", name);
    // Display the final amount
    printf("The final amount after applying the discount is: Rs.%.2f\n", finalAmount);
    printf("Thanks For Shopping...");
    return 0;

}

No comments:

Post a Comment

Write a C program that: 1. Accepts the total purchase amount, customer type, and season from the user. 2. Uses nested if-else statements to calculate and display the final amount after applying the discount.

Here is a C Program for Customer and Day Based Shop Management Program  #include <stdio.h> int main () {     char name [ 20 ];     ...

Contact form

Name

Email *

Message *

loading...