As many of the students like chats, chips, juice and chocolates, a vending machine is kept at several places. The person after putting the cash has to enter the product code so as to get it.
The code is as follows
Code Product
106 Haldiram Ratmali Sev
206 Haldiram Instant Bhel
306 Fuse Chocolate
406 Mixed Fruit Juice
506 Lassi
Depending on the code entered the item will be selected and given to the person who feeds the amount.An application has to be developed so that it automatically works after entering the code.
Requirements:
1. Capture the Code
2. Check the code with the existing code and display appropriate product selected
3. If the code is entered wrong it has to display money lost
#include <stdio.h>
int main()
{
int code;
float cash;
printf("Enter cash: ");
scanf("%f",&cash);
printf("Enter code: ");
scanf("%d",&code);
if(code==106 ){
printf("\nProduct Haldiram Ratmali Sev is selected\n");
}else if(code==206 ){
printf("\nProduct Haldiram Instant Bhel is selected\n");
}else if(code==306){
printf("\nProduct Fuse Chocolate is selected\n");
}else if(code==406 ){
printf("\nProduct Mixed Fruit Juice is selected\n");
}else if(code==506 ){
printf("\nProduct Lassi is selected\n");
}else{
printf("\nMoney lost\n");
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment