Here's my code:
Code:
while(1){
q1=0;
q2=0;
q3=0;
q4=0;
printf("Enter store code and quantity: "); //Outputs this line repeatedly
scanf("%c%d %d", &t, &m, &q);
if (t=='E'){ //Everything past here is non essential to the problem, I'd think...
if(m==25){
q1=q;
q1=18.*q1;
total=total+(float)q1;
printf("\n%d Ethernet cables (25 foot) costs $%d.00 (total = $%.2f)\n", q,q1,total);
}else if(m==50){
q2=q;
q2=30.*q2;
total=total+(float)q2;
printf("\n%d Ethernet cables (50 foot) costs $%d.00 (total = $%.2f)\n", q,q2,total);
}
}else if(t=='U'){
if(m==6){
q3=q;
q3=24.*q3;
total=total+(float)q3;
printf("\n%d USB cables (6 foot) costs $%d.00 (total = $%.2f)\n", q,q3,total);
}else if(m==10){
q4=q;
q4=36.*q4;
total=total+(float)q4;
printf("\n%d USB cables (10 foot) costs $%d.00 (total = $.2%f)\n", q,q4,total);
}
}else if(t=='Q'){
break;
}
}
What's happening is that it double posts the ''Enter store code and quantity:'' line, and I have no idea why.
My output looks like this:
Enter store code and quantity: E50 1
1 Ethernet cables (50 foot) costs $30.00 (total = $30.00)
Enter store code and quantity: E50 1
Enter store code and quantity:
1 Ethernet cables (50 foot) costs $30.00 (total = $60.00)
Enter store code and quantity: _