Answer to Question #259595 in C for fas

Question #259595

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


1
Expert's answer
2021-11-03T07:44:05-0400


#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;  
}  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS