As there is lock down everywhere, and the time allocated for shopping is restricted, Mr. Umar
goes for shopping in the specified time, He went to vegetable super market, He purchased some
vegetables and fruits the total bill was “m” Rs. and he got a discount of 10% there. Next he went
to Buy n Save shop and purchased the groceries and the bill amount generated there was “n” Rs
and here he got a discount of 12.5%. Later he went to buy medicine and there the bill was “p”
Rs. and there also he got a discount of 18%.
His mother asked the bill details and the total amount he spent today. Help to create a C
application for the same.
Requirements.
1. Capture the bill m,n,p
2. Compute the amount paid at individual place after discount
3. Display the bill amount paid at each place
4. Calculate the total amount spent
5. Display the total amount spent by Mr. Umar
#include <stdio.h>
int main() {
double m, n, p;
double totalAmount;
printf("Please input the total bill at the vegetable super market (Rs):\n");
scanf("%lf", &m);
printf("Please input the total bill at the Buy\'n\'Save shop (Rs):\n");
scanf("%lf", &n);
printf("Please input the total bill at the chemists shop (Rs):\n");
scanf("%lf", &p);
if ( m <= 0 || n <= 0 || p <= 0 ) {
printf("Error: all values must be positive numbers greater than zero");
return 0;
}
m = m - ( (m / 100) * 10);
n = n - ( (n / 100) * 12.5);
p = p - ( (p / 100) * 18);
printf("\n==========================\n");
printf("The bill amount paid at the vegetable super market (after discount):\n%.2lf Rs\n", m);
printf("The bill amount paid at the Buy\'n\'Save shop (after discount):\n%.2lf Rs\n", n);
printf("The bill amount paid at the chemists shop (after discount):\n%.2lf Rs\n\n", p);
totalAmount = m + n + p;
printf("The total amount spent by Mr. Umar:\n%.2lf Rs\n", totalAmount);
return 0;
}
Comments
Leave a comment