My code seems to stop working after first prompt for please insert money can anyone tell me where in my code am I lacking.
#include <stdio.h>
int main()
{
char drinkchoice;
float insert;
float money;
float totalinsert;
printf("How much do you wish to insert: ");
scanf("%f", &insert);
if(insert < money)
{
printf("\nPlease insert more money: ");
scanf("%f", &insert);
totalinsert = insert + totalinsert;
}
if(totalinsert < money)
{
printf("\nPlease insert more money: ");
scanf("%f", &insert);
totalinsert = (insert + totalinsert);
}
if(totalinsert < money)
{
printf("\nPlease insert more money: ");
scanf("%f", &insert);
totalinsert = (insert + totalinsert);
}
if(totalinsert < money)
{
printf("\nPlease insert more money: ");
scanf("%f", &insert);
totalinsert = (insert + totalinsert);
}
if(totalinsert == money)
{
printf("\nWhat would you like.");
printf("\nPress 1 for coke:\n,Press 2 for sprite:\n,Press 3 for drpepper: ");
scanf("%c", &drinkchoice);
if(drinkchoice == 1)
printf("here is you coke");
if(drinkchoice == 2)
printf("here is your sprite");
if(drinkchoice == 3)
printf("here is your dr pepper");
}
getchar();
return 0;
}