Retail Outlet Managment System - the 4th

This is a discussion on Retail Outlet Managment System - the 4th within the C Programming forums, part of the General Programming Boards category; It's due on midnight yesterday(11/10/07), so I lost a lot of points from this(maybe lost 70 out of 100). I ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    I need an aid for my unfinished programming.

    It's due on midnight yesterday(11/10/07), so I lost a lot of points from this(maybe lost 70 out of 100). I cannot make up for this lost points, I think. Please somebody help me how to make my program run because it has a lot of error messages. I have updated followings today.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    
    #define MAX_TBL_SIZE 30, MIN_STOCK_LEVEL 10 
    
    int index, number, input_item_id, input_item_stock, ItemId, Stock, Sufficient, 
       qty_sold, qty_new, input_item_id;;
    float UnitPrice;
    char file_name[100];
    int num, r, c;
    void ActionCode(int [8]);
    void input(int input_item_id[index], int input_item_stock[index], 
       float UnitPrice[index]);
    void CURRENTSTATUS(int ItemId[index], int Stock[index], int UnitPrice[index],
       char Sufficient);
     
    
    int main(void) {
       
       FILE *ifp;
      
       fprintf(stderr, "Enter the name of the input file: \n");
       fscanf(ifp, "&#37;d", &num);
       ifp = fopen("file_name", "r");
       ActionCode([8]);
       input(input_item_id, input_item_stock, UnitPrice);
       CURRENTSTATUS(ItemId, Stock, UnitPrice, Sufficient);
     
       system("PAUSE");
       return 0;
    }   
     
    void input(int input_item_id[index], int input_item_stock[index], float 
       UnitPrice[index]){
       while(input_item_id[index] != 0 && input_item_stock[index] != 0 
       && UnitPrice[index] != 0){
     
          fscanf(ifp, "%d", &input_item_id[index]);
          fscanf(ifp, "%d", &input_item_stock[index]);
          fscanf(ifp, "%f", &UnitPrice[index]);
    
          index++;
    } 
    
    void CURRENTSTATUS (int ItemId[index], int Stock[index], int 
       UnitPrice[index], char Sufficient){
       
       if(input_item_stock < MIN_STOCK_LEVEL)
          fprintf(stdout, "No", &Sufficient);            
       else
          fprintf(stdout, "Yes", &Sufficient);
          fprintf(stdout, "CURRENT STATUS\n");
          fprintf(stdout, "Id\tStock\tPrice\tSufficient\n");
          fprintf(stdout, "%d\t%d\t%.2f\t%c\n", ItemId[index], Stock[index],
          UnitPrice[index], Sufficient); 
    
    void ActionCode(int *){
       int [8] = {1, 2, 3, 4, 5, 6, 7, 8};
                     
       while ((c =fgetc(ifp)) != EOF) {   
          int number=1;
          switch (number){
    while(number != 0){
    
                case 1:
                   CURRENTSTATUS(ItemId, Stock, UnitPrice, Sufficient);                                 
                   break;
                case 2:
                   if(Stock[index] == 0)
                   fprintf(stdout, "There is no item with id %d.\n", 
                   ItemId[index]);
                   break; 
                case 3:
                   fprintf(ofp, "After sale, there are %d items with id %d.\n", 
                   qty_sold, ItemId);
             
                   if(qty_new < MIN_STOCK_LEVEL){
                   fprintf(stdout, "This product needs to be reordered.\n");
                   }
                   break;    
                case 4: /* input_item_id == 1 */ 
                   fprintf(ofp, "After purchase, there are %d items with id %d.\n", 
                   qty_new[index],ItemId[index]); 
                
                      if(qty_new < MIN_STOCK_LEVEL){
                      fprintf(stdout, "This product needs to be reordered.\n");
                      }
                   break;
                case 5:
                   if(qty_new < MIN_STOCK_LEVEL){
                      fprint(stdout, "Items to be reordered\n");
                      fprint(stdout, "%d\n", ItemId[index]);
                      }
                   break;
                case 6:
                   if  (qty_new <= 1){
                   printf("Lowest Stock: Only %d items left with id %d.\n", 
                   qty_new[index], ItemId[index]);
                   fprintf(stdout, "URGENT ORDER - this product needs to be"}; 
                   fprintf(stdout, "re-ordered\n"); 
                   fprintf(stdout, "immediately.\n");
                   }
                   break;
                case 7:
                   Unitprice[index] += (Stock[index]) * (UnitPrice[index]);
                   UnitPrice[index] += (Stock[index]) * (UnitPrice[index]);
                   fprintf(stdout, "Total price of all the items: $.2f\n", 
                   UnitPrice[index]);
                   break;
                case 8:
                   fprintf(stdout, "Good Bye!\n");
                   break;
             }  
          }        
       }
    }
    Followings are error messages:

    [code]
    23 G:\retail.c [Warning] built-in function 'index' declared as non-function
    G:\retail.c In function `main':
    42 G:\retail.c syntax error before '[' token
    43 G:\retail.c [Warning] passing arg 1 of `input' makes pointer from integer without a cast
    43 G:\retail.c [Warning] passing arg 2 of `input' makes pointer from integer without a cast
    43 G:\retail.c incompatible type for argument 3 of `input'
    44 G:\retail.c [Warning] passing arg 1 of `CURRENTSTATUS' makes pointer from integer without a cast
    44 G:\retail.c [Warning] passing arg 2 of `CURRENTSTATUS' makes pointer from integer without a cast
    44 G:\retail.c incompatible type for argument 3 of `CURRENTSTATUS'
    G:\retail.c In function `input':
    55 G:\retail.c `ifp' undeclared (first use in this function)
    (Each undeclared identifier is reported only once
    for each function it appears in.)
    G:\retail.c In function `CURRENTSTATUS':
    65 G:\retail.c `MIN_STOCK_LEVEL' undeclared (first use in this function)
    G:\retail.c In function `ActionCode':
    74 G:\retail.c parameter name omitted
    75 G:\retail.c syntax error before '[' token
    G:\retail.c In function `CURRENTSTATUS':
    117 G:\retail.c `ofp' undeclared (first use in this function)
    134 G:\retail.c subscripted value is neither array nor pointer
    163 G:\retail.c subscripted value is neither array nor pointer
    164 G:\retail.c syntax error before '}' token
    178 G:\retail.c `Unitprice' undeclared (first use in this function)
    Last edited by Presidentofusa; 11-11-2007 at 12:25 PM.

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    3
    /*
    Objectives:

    To learn concepts of file handling and array manipulation.

    Description:

    In this assignment, it is desired to develop a retail outlet management system.

    Every item handled by the outlet is given a unique id. The system should have

    provision to record price and stock of each item. You need to read the

    information on id (integer), stock (integer) and price (float) for various items

    from the input file and store these in three separate arrays.

    The outlet does not wait for an item to be exhausted before reordering. As soon

    as the item stock goes below a satisfactory level, it is reordered.

    You need to develop separate functions to carry out various actions. The

    original inventory and the various actions to be carried out will be read from

    an input file. The various actions are indicated through the action codes

    described below:

    Action code: 1
    action desired: Generate report on all items
    Print the contents of the three arrays. Each output line should contain the item
    id, its stock level, unit price of the item, and an indication of whether or not
    there is sufficient level of that item in stock.

    action code: 2
    action desired: Generate report on one specific item
    For the given item id, print out the quantity (stock) and the unit price of that
    item.

    action code: 3
    action desired: Selling
    For the given item id, reduce the stock level of the item by the number of items
    sold.


    action code: 4
    action desired: Purchasing
    For the given item id, increase the stock level of the item by the quantity
    purchased.

    action code: 5
    action desired: Order
    List out the ids of the items which need to be reordered.

    action code: 6
    action desired: Urgent-order
    List the item that must be ordered immediately (one whose stock is the lowest).
    Assume that there will be exactly one such item.

    action code: 7
    action desired: Total retail
    Print the total value of all the items put together (multiply unit price of each
    item with its stock and total up everything).

    action code: 8
    action desired: Exit
    Print "Good Bye!" and terminate the program.


    The Input File

    Prompt the user to enter the name of the input data file. It is guaranteed that
    the user will enter a valid file name. The file starts with information about
    the various items in the retail outlet.

    Each line will contain information for one item in the following order:
    item id (positive integer),
    stock (positive integer)
    and unit price (positive float).

    It is guaranteed that the retail outlet will not have more than 30 items.
    (#define MAX_TBL_SIZE as 30 and declare each of your three arrays to be of size
    MAX_TBL_SIZE.)

    As you read in the information from each line, store the values in three
    separate arrays. Stop storing the values when you get to the line containing
    three zeros, i.e., values provided for item id, stock and unit price are zero.
    This input line signifies the end of the current inventory (situation of the
    retail outlet) and you should stop storing values in the three arrays.

    Assume the satisfactory stock level for each item is 10 (#define MIN_STOCK_LEVEL
    as 10 and use MIN_STOCK_LEVEL throughout your program).

    The remaining lines in the input file specify the actions to be carried out.
    The first integer on each line will specify the desired action, followed by
    other parameters if necessary. These are explained in the data processing part
    which follows.


    Data Processing and Output:

    Once you have stored the current status of the retail store, start reading the

    action lines from the input file.

    As you read each line from the input file, print it out. Then perform the action

    and print the output for each code, as per the format specified in the sample

    output. The processing for each action code is indicated below:

    1
    This line will not have any other parameters. Print the current status of retail
    outlet as explained in action code 1 above.

    2
    This line will contain one more integer which indicates an item id. Search your
    item id array and when you locate input_item_id, print the item id, and its
    corresponding stock and unit price. If the specified id is not found in the
    item id array, then print "There is no item with id input_item_id".

    3
    This line will contain two more integers input_item_id and qty_sold. For the
    given item, reduce qty_sold from its corresponding stock (assume the item exists
    in the inventory). Print id and the new value of stock for that item. If the
    item needs to be reordered, print "This product needs to be reordered".

    4
    This line will contain two more integers input_item_id and qty_new. For the
    given item, add qty_new to its corresponding stock (assume the item exists in
    the inventory). Print id and the new value of stock for that item.

    5
    This line will not have any other parameters. Examine the stock array, and print
    the ids of items which need to be reordered.

    6
    This line will not have any other parameters. Examine the stock array, and print
    the id for the item whose stock value is lowest of all (assume there will be
    exactly one such item). If the stock level is below satisfactory, then print
    "URGENT ORDER - this product needs to be re-ordered immediately".

    7
    This line will not have any other parameters. Perform the action outlined in
    action code 7 above.

    8
    This line will not have any other parameters. Perform the action outlined in
    action code 8 above.


    Sample Input File

    23 20 10.00 /* These are item number, stock and unit price */
    30 15 5.50
    47 25 7.00
    93 6 30.0
    52 10 6.00
    86 16 4.00
    66 25 8.50
    0 0 0
    1 /* ActionCode 1/
    2 47 /* ActionCode 2 and item id 47/
    2 13 /* ActionCode 2 and item id 13/
    3 86 7 /* ActionCode 3 item id 86, and item sold 7/
    4 47 5 /* ActionCode 4, item id 47, and item purchased 5/
    3 23 15 /* ActionCode 3, item id 23, and item sold 15/
    3 66 5 /* ActionCode 3, item id 66, and item sold 5/
    5 /* ActionCode 5/
    6 /* ActionCode 6/
    1 /* ActionCode 1/
    7 /* ActionCode 7/
    8 /* ActionCode 8/

    this input should print out following without stopping or prompting.

    1
    CURRENT STATUS
    Id Stock Price Sufficient
    23 20 10.00 Yes
    30 15 5.50 Yes
    47 25 7.00 Yes
    93 6 30.00 No
    52 10 6.00 Yes
    86 16 4.00 Yes
    66 25 8.50 Yes

    2 47
    25 items with id 47 and unit price $7.00.

    2 13
    There is no item with id 13.

    3 86 7
    After sale, there are 9 items with id 86.
    This product needs to be reordered.

    4 47 5
    After purchase, there are 30 items with id 47.

    3 23 15
    After sale, there are 5 items with id 23.
    This product needs to be reordered.

    3 66 5
    After sale, there are 20 items with id 66.

    5
    Items to be reordered
    23
    93
    86

    6
    Lowest stock: Only 5 items left with id 23.
    URGENT ORDER - this product needs to be re-ordered
    immediately.

    1
    CURRENT STATUS
    Id Stock Price Sufficient
    23 5 10.00 No
    30 15 5.50 Yes
    47 30 7.00 Yes
    93 6 30.00 No
    52 10 6.00 Yes
    86 9 4.00 No
    66 20 8.50 Yes

    7
    Total price of all the items: $788.50

    8
    Good Bye!
    Last edited by Presidentofusa; 11-11-2007 at 08:36 AM.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Unhappy Final Code

    Does anyone have the final code to share i am lost

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    3
    can someone please post the code for this program, its highly confusing. i have been working on this all day, it reads my file, but keeps exiting doesn't show the info from the retail.txt file. someone please post the code and show some light on this program. thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 10:13 AM
  2. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 07:16 AM
  3. Operating system construction
    By AdamLAN in forum Tech Board
    Replies: 7
    Last Post: 03-05-2005, 01:31 PM
  4. exe files in -c- language
    By enjoy in forum C Programming
    Replies: 6
    Last Post: 05-18-2004, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21