I tried to use for loop calculate the number of books keyed in and sum up their total price, but at the end i only get zero price in C program. What is my problem ? How to solve it?
 #include<stdio.h>     
 int main(void)          
 {      
        int booknum;                  
        float bookfee,bookgst,nogst,totfee,newfee,newfee_nogst;           
        bookgst=0.0;                
        nogst=0.0;                
        int cnt;                    
        char code;                           
        printf("Key in total books purchased >> ");                 
        scanf("%d",&booknum);
        for(cnt=1;cnt<=booknum;cnt++)
        {
            printf("\n\n");
            printf("Key in price of the book >> ");
            scanf("%f",&bookfee);
            printf("Key in type( S=standard gst,Z=zero gst) \n>> ");
            scanf("%c",&code);
            getchar();
            if(code=='S')
            {
                newfee=bookfee+0.6;
            }
            else if(code=='Z')
            {
                newfee_nogst=bookfee;
            }
            bookgst=bookgst+newfee;
            nogst=nogst+newfee_nogst;
            printf("\n");
        }
        totfee=bookgst+nogst;
        printf("Book purchased with GST    : RM %.2f\n",bookgst);
        printf("Book purchased without GST : RM %.2f\n",nogst);
        printf("Total payment              : RM %.2f\n",totfee);
        return 0;
    }
 
    