In: Computer Science
Bibi loves to go shopping. One day, one of her favorite stores is offering a discount. Bibi becomes very interested and decided to shop there. If Bibi’s current total is N Rupiah before X% discount and Y % tax, how much should Bibi pay to the cashier?
Format Input :
A single line with three integers N , X and Y .
Format Output :
A single line of the amount of money Bibi has to pay in two decimal places.
Constraints :
Sample Input 1 :
10000 10 10
Sample Output 1 :
9900.00
Sample Input 2 :
90000 5 15
Sample Output 2 :
98325.00
Sample Input 3 :
43250 7 10
Sample Output 3 :
44244.75
Explanation :
On the first sample, the price of the item after a 10% discount is 9000.00. After discounting the price, we apply a 10% tax on top of it so Bibi owes the cashier 9900.00.
NOTES :
IN C LANGUAGE
I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments(read them for better understanding).
Images of the Code:
Note: If the below code is missing indentation please refer code Images
Typed Code:
/*Header files*/
#include <stdio.h>
#include <math.h>
int main()
{
/*declaring double and int variables*/
double p;
int d,t;
/*getting inputs from the user
price, discount, tax*/
printf("Enter Price of the item: ");
scanf("%lf",&p);
printf("Enter discount of the item: ");
scanf("%d",&d);
printf("Enter tax of the item: ");
scanf("%d",&t);
/*if price greater than or equal to pow(10,3) and
less than or equal to pow(10,9)*/
if(p>=pow(10,3) && p<=pow(10,9))
{
/*if discount and tax greater than or equal to 1 and
less than or equal to 100*/
if((d>=1 && d<=100)&&(t>=1 &&
t<=100))
{
/*finding discount using formula
(discount percentage*price)/100*/
double a = (d*p)/100;
/*subtracting discount from price*/
p = p-a;
/*finding tax using formula
(tax percentage*price)/100*/
double b = (t*p)/100;
/*adding tax to price*/
p = p+b;
/*printing the final price*/
printf("Bibi pay to the cashier : %.2lf",p);
}
/*if the given conditions fails*/
else
{
/*printing that the discount or tax is not in the given
range*/
printf("Enter discount or tax in given range");
}
}
/*if the given conditions fails*/
else
{
/*printing that the price is not in the given range*/
printf("Enter price in given range");
}
return 0;
}
/*code ended here*/
Output:
If You Have Any Doubts. Please Ask Using Comments.
Have A Great Day!