donmike25 icon

ecp1016 tutorial 3(3)

donmike25 | PRO | 06/27/13 01:21:22 PM UTC | 0 ⭐ | 240 👁️ | Never ⏰ | []
C |

510 B

|

None

|

0 👍

/

0 👎

#include<stdio.h>
int main()
{
int x;
float price;
char y;
 
printf("Please enter price of product (RM) and discount colour code (R, G or B):\n");
scanf ("%d%c",&x,&y);
printf("RM %d\n",x);
 
if ( y== 'r' || y== 'R')
{
price= x-(x*0.20);
printf("The actual price is RM%.2f\n", price);
}
 
else if ( y== 'g' || y== 'G')
{
price= x-(x*0.15);
printf("The actual price is RM%.2f\n",price);
}
 
else if ( y== 'b' || y== 'B')
{
price= x-(x*0.10);
printf("The actual price is RM%.2f\n",price);
}
 
return 0;
}

Comments