0
1.7kviews
An electronic component vendor supplies three products: transistors, resistors and capacitors. The vendor gives a discount of 10% on order for transistors if the order is more than Rs. 1000.

On order of more than Rs. 100 for resistors, a discount of 5% is given and discount of 10% is given on orders for capacitors of value more than Rs. 500. Assume numeric code 1, 2 and 3 used for transistors, capacitors and resistors respectively. Write a program that reads the product code and the order amount, and prints out the net amount that the customer is required to pay after discount.

Subject : Structured Programming Approach

Title : Control Structures

Difficulty : Medium

1 Answer
1
10views

Program:

#include<stdio.h>

#include<conio.h>

void main()

{

    int choice,n,dis;

    clrscr();

    printf("\n1.Transistor\n2.Capacitor\n3.Resistor\nEnter your choice");

    scanf("%d",&choice);

    printf("Enter the price");

    scanf("%d",&n);

    switch(choice)

    {

        case 1:if(n>1000)

        {

            dis=n/10;

            dis=n-dis;

            printf("The total price after discount is %d",dis);

        }

        else

        {

            dis=n;

            printf("The total price is %d",dis);

        }

        break;

        case 2:if(n>500)

        {

            dis=n/10;

            dis=n-dis;

            printf("The total price after discount is %d",dis);

        }

        else

        {

            dis=n;

            printf("The total price is %d",dis);

        }

        break;

        case 3:if(n>100)

        {

            dis=n/5;

            dis=n-dis;

            printf("The total price after discount is %d",dis);

        }

        else

        {

            dis=n;

            printf("The total price is %d",dis);

        }

        break;

        }

    getch();

}

Output:

1.Transistor

2.Capacitors

3.Resistor

Enter your choice 1

Enter the price 1050

The total price after discount is 945
Please log in to add an answer.