Computer Science, asked by leatanui98, 1 year ago

a shop gives a discount of 10% if the cost of purchased quantity is more than 1000.Ask a user for the quantity supposing that one unit cost 100 print the total cost for user

Answers

Answered by mridul2082
72
print "Enter quantity" quantity = input() if quantity*100 > 1000: print "Cost is",((quantity*100)-(.1*quantity*100)) else: print "Cost is",quantity*100
Answered by mad210219
21

Given:

A shop gives a discount of 10% if the cost of purchased quantity is more than 1000.

To find:

Print the total cost for user

Solution:

C program:

#include<stdio.h>

int main(){

int quantity;

float totalcost;

Printf(“enter quantity”);

Scanf(“%d”,&quantity);

If(quantity*100>1000)  

{

totalcost= ((quantity*100)-((10*(quantity*100)/100))  

//SUBTRACTING DISCOUNT FROM ORIGINAL AMOUNT

}

else

{

totalcost=quantity*100;  

//CALUCLATING TOTAL COST 100 PER UNIT

}

printf(“the total cost is %f”,totalcost);

return 0;

}

OUTPUT:

Enter quantity 20

The total cost is 1800

Explanation:

QUANTITY=20

SO 20\times100=2000

AS 2000 IS GREATER THAN 1000 WE GIVE 10% DISCOUNT  

SO  

10% IN 2000 IS \frac{10\times2000}{100}

SO 10% IN 2000 IS 200

WE CALUCLATE TOTALCOST BY SUBTRACTING

ACCTUAL COST-DISCOUNT COST

SO 2000-200=1800

1800 IS THE TOTALCOST

Similar questions