Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- void getInput(int *milkbottles, int *icecans){
- printf("1 bottle of milk = 15.25 pesos\n");
- printf("1 half-gallon can of ice cream = 100.00 pesos\n");
- printf("We offer 5 percent discount on total milk price for 10 or more bottles of milk ordered\n");
- printf("We also offer 7 percent discount on total ice cream price for 3 or more cans of ice cream ordered\n");
- printf("\nHow many bottles of milk will you purchase: ");
- scanf("%d",milkbottles);
- printf("How many half-gallon cans of ice cream will you purchase: ");
- scanf("%d",icecans);
- }
- float milk(int milkbottles){
- float milkprice;
- if (milkbottles<10){
- milkprice=milkbottles*15.25;
- }
- if(milkbottles>=10){
- milkprice=milkbottles*15.25;
- milkprice=milkprice-milkprice*0.05;
- }
- printf("\nTotal cost of Milk purchase: %.2f",milkprice);
- return milkprice;
- }
- float ice(int icecans){
- float iceprice;
- if (icecans<3){
- iceprice=icecans*100;
- }
- if(icecans>=3){
- iceprice=icecans*100;
- iceprice=iceprice-iceprice*0.05;
- }
- printf("\nTotal cost of Ice Cream purchase: %.2f",iceprice);
- return iceprice;
- }
- float totalcost(float iceprice, float milkprice, float total){
- total = iceprice+milkprice;
- printf("\n%.2f",total);
- return total;
- }
- int main(){
- int milkb;
- int icec;
- int icecreamc;
- int milkbottles;
- int icecans;
- float iceprice;
- float milkprice;
- float total;
- printf(" Gatas Ng Kalabaw Dairy Product Company \n");
- printf("Pasteurized Milk And Ice Cream Order Machine \n\n");
- printf("Please input the following: ");
- getInput(&milkb,&icecreamc);
- milkprice = milk(milkbottles);
- iceprice = ice(icecans);
- total = totalcost(iceprice, milkprice, total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement