donmike25

ecp1016 tutorial 3(3)

Jun 27th, 2013
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int x;
  5. float price;
  6. char y;
  7.  
  8. printf("Please enter price of product (RM) and discount colour code (R, G or B):\n");
  9. scanf ("%d%c",&x,&y);
  10. printf("RM %d\n",x);
  11.  
  12. if ( y== 'r' || y== 'R')
  13. {
  14. price= x-(x*0.20);
  15. printf("The actual price is RM%.2f\n", price);
  16. }
  17.  
  18. else if ( y== 'g' || y== 'G')
  19. {
  20. price= x-(x*0.15);
  21. printf("The actual price is RM%.2f\n",price);
  22. }
  23.  
  24. else if ( y== 'b' || y== 'B')
  25. {
  26. price= x-(x*0.10);
  27. printf("The actual price is RM%.2f\n",price);
  28. }
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment