By using switch..case statement, construct a console program using C language to display the book price that entered by the customer and then display the new book price after the discounts. The customer needs to enter the code and the discount will be given to the customer based on the code entered by them.
Code 1 : 10% discount
Code 2 : 15% discount
Code 3 : 17% discount
Others : 5% discount
//main function
int main()
{
int code=0;//code
printf("Enter code: ");//enter code
scanf("%d",&code);
switch(code){//switch
//show result
case 1:
printf("10% discount");
break;
case 2:
printf("15% discount");
break;
case 3:
printf("17% discount");
break;
default:
printf("5% discount");
break;
}
scanf("%d",&code);//dealy
return 0;
}