Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. void getInput(int *milkbottles, int *icecans){
  5.  
  6. printf("1 bottle of milk = 15.25 pesos\n");
  7. printf("1 half-gallon can of ice cream = 100.00 pesos\n");
  8. printf("We offer 5 percent discount on total milk price for 10 or more bottles of milk ordered\n");
  9. printf("We also offer 7 percent discount on total ice cream price for 3 or more cans of ice cream ordered\n");
  10. printf("\nHow many bottles of milk will you purchase: ");
  11. scanf("%d",milkbottles);
  12. printf("How many half-gallon cans of ice cream will you purchase: ");
  13. scanf("%d",icecans);
  14.  
  15. }
  16.  
  17. float milk(int milkbottles){
  18. float milkprice;
  19. if (milkbottles<10){
  20. milkprice=milkbottles*15.25;
  21. }
  22. if(milkbottles>=10){
  23. milkprice=milkbottles*15.25;
  24. milkprice=milkprice-milkprice*0.05;
  25. }
  26. printf("\nTotal cost of Milk purchase: %.2f",milkprice);
  27. return milkprice;
  28. }
  29. float ice(int icecans){
  30. float iceprice;
  31. if (icecans<3){
  32. iceprice=icecans*100;
  33. }
  34. if(icecans>=3){
  35. iceprice=icecans*100;
  36. iceprice=iceprice-iceprice*0.05;
  37. }
  38. printf("\nTotal cost of Ice Cream purchase: %.2f",iceprice);
  39. return iceprice;
  40. }
  41.  
  42. float totalcost(float iceprice, float milkprice, float total){
  43. total = iceprice+milkprice;
  44. printf("\n%.2f",total);
  45. return total;
  46. }
  47. int main(){
  48. int milkb;
  49. int icec;
  50. int icecreamc;
  51. int milkbottles;
  52. int icecans;
  53. float iceprice;
  54. float milkprice;
  55. float total;
  56.  
  57. printf(" Gatas Ng Kalabaw Dairy Product Company \n");
  58. printf("Pasteurized Milk And Ice Cream Order Machine \n\n");
  59. printf("Please input the following: ");
  60. getInput(&milkb,&icecreamc);
  61. milkprice = milk(milkbottles);
  62. iceprice = ice(icecans);
  63. total = totalcost(iceprice, milkprice, total);
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement