Program for inventory report

Program 14) The ABC Electric Company manufactures four consumer products. their inventory position on a particular day is given below:

      Code                        Quantity              Rate(Rs)
       F105                         275                       575.00
       H220                        107                        99.95
       1019                         321                        215.50
       M315                        89                         725.00

It is required to prepare the inventory report table in the following format:
                               INVENTORY REPORT 
      Code              Quality             Rate          Value
       ____               _____               ____          _____
       ____               _____               ____          _____
       ____               _____               ____          _____
       ____               _____               ____          _____
                                                 Total value    _____
The value of each item is given by the product of quantity and rate.
This program reads the data from the terminal and generates the required output. 


                                  PROGRAM

#define ITEMS 4
main( )
 {
        int i, quantity[5] ;
        float rate[5], value, total_value ;
        char code[5] [5] ;
        i = 1 ;
        while(i <= ITEMS)
         {
                 printf("Enter code, quantity, and rate:") ;
                 scanf("%s %d %f", code[1], &quantity[i],
                                          &rate[i]) ;
                 i++ ;
         }
       /*....Printing of table and column Headings....*/
         printf("\n\n") ;
         printf("           INVENTORY REPORT       \n") ;
         printf("-----------------------------------------------\n") ;
         printf("   Code  Quantity  Rate  Value   \n") ;
         printf("-----------------------------------------------\n") ;
      /*....Preparation of inventory position....*/
         total_value = 0 ;
         i = 1 ;
         while(i <= ITEMS) 
          {
                  value = quantity[i] * rate[i] ;
                  printf("%5s %10d %10.2f %e\n", code[i],
                               quantity[i], rate[i], value) ;
                  total_value += value ;
                  i++ ;
          }
     /*....Printing of End of table....*/
       printf("------------------------------\n") ;
       printf("                  Total value = %e\n", total_value) ;
       printf("------------------------------\n") ;
       getch( ) ;
 }


Output:        
            Enter code, quantity, and rate:F105  275   575.00
            Enter code, quantity, and rate:H220  107   99.95
            Enter code, quantity, and rate:I0I9    321   215.50
            Enter code, quantity, and rate:M315  89    725.00
                                   
                               INVENTORY REPORT
      _______________________________________________
      Code              Quantity          Rate                Value
     ________________________________________________
     F105                     275             575.00        1.581250e+005
     H220                     107              99.95        1.069465e+004
     I0I9                        321             215.50       6.917550e+004
     M315                     89               725.00       6.452500e+004
     ________________________________________________
                                              Total Value = 3.025202e+005
    ________________________________________________



No comments:

Post a Comment