Computer Science, asked by barnali12, 9 months ago

A manufacturer sells an item for Rs. 100 each. For the first 100 items there is no discount. If you order between 101 and 200 items there is a 10 % discount on each item other than the first 100. If you order more than 200 items, then for the first 100 there is no discount; for the next 100 there is a 10 % discount, and for each item above 200 there is a 20 % discount. Thus if you order 30, the cost is Rs 3000. If you order 130, the cost is Rs. 12700. If you order 230, then the cost is Rs. 10000+9000+2400 = 21400. The following program fragment is supposed to calculates the cost.

int quantity; cin >> quantity;
int cost = 0;
if(quantity <= 100) cost = blankA1 + quantity * blankA2;
else if(quantity <= 200) cost = blankB1 + (quantity - 100) * blankB2;
else cost = blankC1 + (quantity - 200) * blankC2;
cout << cost;

In the above, all the blanks are to be filled using just numbers (no expressions or variables allowed). Also, if multiple values are asked give them comma separated.



1>What is the value of blankA1,blankA2?

2>What is the value of blankB1,blankB2?

3>What is the value of blankC1,blankC2?

Answers

Answered by Raghav1330
3

Answer:A1-0

A2-100

B1-10000

B2-90

C1-19000

C2-80

Explanation:

See, in this given code the price distribution is given and it's discount.

For first when there are less than 100 items there are no discount hence A2 will be int quantity*100 and A1 will be zero there's no previous cost to be added on this.

For second case when quantity is less than 200 then for the first 100 products it will be 100*100=10000, which explains why B1 value is 10000. For the remainder of items after 100 items we will have 10%discount hence the price of all those rest of products will be 90. So in the given code segment it is given (quantity-100)*90.

For the products extra to first 100 items will be multiplied by discount price 90. Hence B2 is 90. As given in the example if we buy 130 items it will be distributed as 10000+30*90=12700. Now for c1 the answer is 100*100+100*90=19000. Hence value of 'C1 is 19000. For c2 we have the else case of any purchase of over 200 items we will have 20% discount, hence the price of every 201st product onwards cost price will be 80. Therefore the C2 is 80. In the example if we buy 230 products then the price distribution will be 10000+9000(as explained earlier)+2400(30*80)

Similar questions