Flipkart is providing a discount to customers based on the purchases made. Ramachandra has purchased some items, he would like to know his bill. Following are the requirements to solve the problem
a) For purchases less than Rs 1000, the discount is 10% b) For purchases greater than and equal to Rs 1000 and less than 1500 the discount is 12%
c) For purchases greater than and equal to Rs 1500 the discount is 14% 4) Capture the purchased amount by Ramachandra
e) Display Ramachandra's final bill
#include<stdio.h>
int main(){
float purchasesMade=0;
float discount=0;
printf("Enter the purchases made: ");
scanf("%f",&purchasesMade);
//a) For purchases less than Rs 1000, the discount is 10% b)
if(purchasesMade<1000){
discount=0.1;
}
//For purchases greater than and equal to Rs 1000 and less than 1500 the discount is 12%
if(purchasesMade>=1000 && purchasesMade<1500){
discount=0.12;
}
//c) For purchases greater than and equal to Rs 1500 the discount is 14%
if(purchasesMade>=1500){
discount=0.14;
}
//d) Capture the purchased amount by Ramachandra
purchasesMade-=purchasesMade*discount;
//e) Display Ramachandra's final bill
printf("\nRamachandra's final billed by Ram is: Rs %.2f\n\n",purchasesMade);
getchar();
getchar();
return 0;
}
Comments
Leave a comment