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;

}

How to I fix Errors on Messenger ?

Fix the 'Unfortunately, Facebook Messenger has stopped' error
Open Settings.
 Select the Apps or Apps & notifications option. 
Tap See all Apps.
 In the app list, select Messenger. 
Select Storage & cache.
 Tap Clear cache. 
On older Android versions, the Clear cache option will be shown on the previous screen.

Program of Copy Constructor

 #include<iostream>

#include<conio.h>

using namespace std;

class Box

{

private:

    float l,b,h;

public:

    Box(float le, float br, float he)

   {

   l=le;

   b=br;

   h=he;

   }

   Box(Box &b2)

   {

       l=b2.l;

       b=b2.b;

       h=b2.h;

   }

   void DisplayMembers()

   {

       cout<<"\nLength:"<<l;

       cout<<"\nBreadth:"<<b;

       cout<<"\nHeight:"<<h;

   }

float getVolume()

{

    return l*b*h;

}

};

int main()

{

float vol;

Box b1(10.5,5.5,6.5);

Box b2(b1);

cout<<"___________For the First Object b1_______________:";

b1.DisplayMembers();

vol=b1.getVolume();

cout<<"\nThe Volume of Box is:"<<vol;

cout<<"\n___________For the second Object b2_______________:";

b2.DisplayMembers();

vol=b2.getVolume();

cout<<"\nThe Volume of Box is:"<<vol;

getch();

return 0;

};

                          Output of copy constructor


OUTPUT


 

Read Data Member of class using construction. find volume with constructor..

Find the volume of Box using construcor   ..

image is taken ffom another website

 



#include<iostream>

#include<conio.h>

using namespace std;

 class Box

 {

private:

    float l,b,h;

public:

    Box(float le, float br, float he)

    {

        l=le;

        b=br;

        h=he;

    }

    float getvolume()

    {

        return(l*b*h);

    }

 };

 int main(){

 float vol;

 Box ob(10,3.5,5.5);

 vol=ob.getvolume();

 cout<<"The volume of Box is:"<<vol;

 return 0;

 getch();

 };


Class and Object Source code

This code is written by sagar dhakal.

for the educational purpose.....




 #include <iostream>


using namespace std;

class box

{

private:

    float l,b,area;

public:

    void readdata()

    {

        cout<<"\t\t\t*****************************";

        cout<<"\n\t\t\t\tWELCOME BY THE SAGAR DHAKAL\n\t\t\t_____________________________";

        cout<<"\n\n\t\tTo find Area of Square and rectangle\n\n\t1.Enter the value of length\n---->";

        cin>>l;

        cout<<"\n\t2.Enter the value of breadth\n---->";

        cin>>b;

    }

    void displayarea()

    {

    area=l*b;

    cout<<"The area of the following object is:\n\t\t\t\t"<<area;

    }

};

int main()

{

    box b1;

    b1.readdata();

    b1.displayarea();


    cout << "\n\t\tThank you!" << endl;

    return 0;

}


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...