In the below code I have put together a text example of a shopping cart whereby the user selects a commodity to purchase and based upon a menu selection, tells the program which leg in my switch statement to execute. After a selection is made, the program drops out of the switch statement and proceeds to the bottom of the while statement where "ordercom" tells the while statement to continue taking orders. This is obviously an un-ending loop but is coded this way to trouble shoot the issue at hand. I am testing the code with code breaks. What is happening is that after I select two menu selections or two loops of the while statement the program skips over the scanf statement.
Can someone help me with this issue?
Code:
#include <stdio.h>
#define Artichoke 1.25
#define Beets .65
#define Carrots .89
#define Discount .05
#define Shipping1 10.00
#define Shipping2 8.00
int main(void)
{
char ordercom;
char type;
float pounds;
float gross;
float poundTot = 0;
ordercom = 'Y';
while(ordercom == 'Y')
{
printf("*******************************************************************************************************************\n");
printf("Determine What You Want To Buy\n");
printf("1) (a)\t Artichokes\t 3) (c)\t Carrots\n");
printf("2) (b)\t Beets\t 4) (q)\t Quit\n");
printf("*******************************************************************************************************************\n");
printf("\n");
printf("Select The Type Of Vegetable You Want And The Pounds Of The Vegetable You Want Or (q) To Quit :");
scanf("%c ""%f",&type,£s);
switch(type)
{
case 'a' :
{
gross = pounds * Artichoke;
break;
}
case 'b' :
{
gross = pounds * Beets;
break;
}
case 'c' :
{
gross = pounds * Carrots;
break;
}
case 'q' :
{
break;
}
default :
{
break;
}
}
ordercom = 'Y';
}
}