I'm a First year IT student
and I'm having a
problem with my
vending machine program..
I can't subtract the cost from the input of the user..
can anyone help me with this simple problem?..
#include<stdio.h>
#include<conio.h>
struct vendingmachine
{
int x,y;
float cost;
double change;
char nikz;
};
main()
{
int a,b,h;
float x =1.75,y =1.90,change;
{
struct vendingmachine nikz[10];
printf("\n\n\n===============================================================================");
printf("======================== Vending Machine of Errors ==========================");
printf("================================================================================\n\n\n\n\n");
printf("Drinks name\t Cost Stock in the machine\n\n\n");
printf("1. Cream soda\t 1.75$\t 20\n");
printf("2. Grape Soda\t 1.75$\t 15\n");
printf("3. Cola\t 1.75$\t 20\n");
printf("4. Lemon-lime\t 1.90$\t 18\n");
printf("5. Root-beer\t 1.90$\t 20\n\n");
printf("6. Do you wish to Exit the Program? \n \n \n");
};
printf("Your choice is :\t");
scanf("%d",&a);
if(a==1)
printf("You have chosen Cream soda\n");
if(a==2)
{printf("You have chosen Grape soda\n");}
if(a==3)
{printf("You have chosen Cola\n");}
if(a==4)
{printf("You have chosen Lemon-lime\n");}
if(a==5)
{printf("You have chosen Root-beer\n");}
if(a==6)
{printf("Thank you come again\n\n\n");
return 1;}
printf("\nEnter your deposit:\t");
scanf("%d",&b);
if(a<=3)
{change=b-x;}
else
{change=b-y;}
printf("Your change is %f");
}