Thread: Can't seem to find the problem, help.

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    Can't seem to find the problem, help.

    I have 4 errors, right at getch, i've scanned through the entire program but unable to come up with the solution.......am I missing something here ?

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    typedef struct part
    {
    int part_num;
    float price;
    }part;
    part parts[25];
    int orderup (int qnt,int rpoint,int mino);
    
    int main()
    {
    int quant;
    int re_order;
    int min_order;
    int i;
    
    printf("\n Benz Auto Supplies Inventory Manager\n");
    for (i=0;i<25;i++){
    printf("Enter part number:");
    scanf("%d",&parts[i].part_num);
    printf("\nPrice of part:");
    scanf("%f",&parts[i].price);
    printf("\nQuantity available:");
    scanf("%d",&quant);
    printf("\nReorder point:");
    scanf("%d",&re_order);
    printf("\nMinimum order:");
    scanf("%d",&min_order);
    printf("\nRe-order point:");
    scanf("%d",&re_order);
    printf("\nThe order amount is:%d",orderup(quant,re_order,min_order));
    printf("End of Report");
    }
    }
    getch();
    return 0;
    }
    int orderup (int qnt,int rpoint,int mino)
    {
     int or;
     if (qnt < rpoint){
             or=rpoint+mino;
             or=or-qnt;   
             
             return or;
             }
             else if (qnt > rpoint){
                  return or;
                  }
                  }

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Learn how to properly indent code it helps a lot to find programming errors.

    Tim S.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Code:
    int orderup (int qnt,int rpoint,int mino)
    {
      int or;
      if (qnt < rpoint){
         or=rpoint+mino;
         or=or-qnt;   
         return or;
      }
      else if (qnt > rpoint) {
        return or;
      }
    }
    I'd change this:
    or=rpoint+mino;

    to:
    Code:
      int or = 0; //assign value to zero
      //add another if (nested) if statement:
      if(qnt < rpoint) {
        or = qnt + mino; //actual amounts of product
        if(or < rpoint) { //you want mino MORE than rpoint, 
          or = rpoint + mino; //or you'll be re-ordering after just 1 sale
          //in R/L, you'd go for the quantity that gave you the best discount, and 
          //include factoring in it's shelf life and sales, that would generate the most 
          //profit, in the shortest amount of time, for this purchase.
          return or;  //return quantity
        }
      }
      return or; //return 0;
    }
    Your instructor may want other constraints, so consider the above just one opinion.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    2
    Hm adak but for my function its suppose to return the order amount not quantity, this is the question:
    i. The order amount is calculated when the quantity on hand falls below the reorder point.

    ii. Order amount is calculated as the sum of the reorder point and the minimum order minus the quantity on hand.

    that's why i structured mine in that manner.......hope it makes sense :s

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    getch(), return 0 are outside of any function. That's why you're getting an error.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Yes, that does make sense.

    OK, we know what the minimum order has to be, but what order is the one we want - the best order?

    Or are you, for the sake of this problem, making every order the minimum order?

    That's what I'm not getting - when you order, how do you calculate the order amount to make, (beyond the minimum order)?

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adak View Post
    Yes, that does make sense.

    OK, we know what the minimum order has to be, but what order is the one we want - the best order?

    Or are you, for the sake of this problem, making every order the minimum order?

    That's what I'm not getting - when you order, how do you calculate the order amount to make, (beyond the minimum order)?
    If this operates like most inventory problems, Adak... the idea is that when the quantity on hand falls below an assigned minimum, you place an order that is either A) the minimum order or B) to replenish stock to an assigned maximum... whichever is more.


    It's like milk... when the jug is less than 1/3 full you go out and buy another jug (the minimum order) or two jugs (the assigned maximum) to replinish your supply.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Some maximum order amount is what I'm not seeing in the code he posted. Is that something that should be added, in this assignment, or not?

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adak View Post
    Some maximum order amount is what I'm not seeing in the code he posted. Is that something that should be added, in this assignment, or not?
    I don't know about this particular assignment but in the real world you need some means to prevent over-ordering or running out...

    Generally there are 4 factors...

    Minimum stock ... the minimum # of an item before ordering more (aka Re-Order level)
    Maximum stock ... How many is too many?
    Actual Stock ... How many do we have right now?
    Minimum Order ... What's the smallest order we can place.

    Lets say (hypothetically) we're talking about rubber balls...

    For the 4 inch size we sell about 100 a month...

    So we can set a Max of 100

    It takes about 10 days for an order to come in and we need to receive the shipment before running out... So we set our Minimum level at 30 which represents 10 days; 1/3 of a month, 1/3 of our monthly sales

    Our minimum order from the factory is a box of 25.

    Now we can track our sales...

    When we get down to 30, we need to order 70 (Max - Actual).

    But they come in boxes of 25, so we have to order 75 (3 boxes).

    When the order comes in we update our Actual level and the cycle begins again...
    Last edited by CommonTater; 03-04-2011 at 02:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can't find the problem (tetris)
    By Sokay in forum C Programming
    Replies: 1
    Last Post: 10-07-2009, 07:29 AM
  2. Getting illegal case error
    By scmurphy64 in forum C Programming
    Replies: 2
    Last Post: 09-17-2009, 10:35 AM
  3. Off by a penny problem
    By ninety3gd in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2009, 05:41 PM
  4. fullscreen toggling problem
    By hannibar in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2005, 08:06 PM
  5. Replies: 4
    Last Post: 08-15-2002, 11:35 AM