Thread: Can anybody help me with the equations for this problem?

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    56

    Can anybody help me with the equations for this problem?

    Basically I need to find the minimum number of packages I need which is the cheapest price.

    I did a*price_small+b*price_large= total cost

    and 200*a+ 50*b = total_invitations

    but since I have to use if statements as well as while loops I don't know how to find the minimum of each. Hope one of you can help.

    Arup wants to just send a free E-vitation to all of his guests for his wedding, his fiancee will have none of it. She has put her foot down and has insisted that they mail out regular invitations. After doing some research, Arup found out that depending on the size of the packages of invitations ordered, there are different prices. He wants you to figure out how many of each package to order, in order to get enough invitations to mail out at the cheapest price. For the purposes of this problem, there are only two packages:

    1) One with 50 invitations
    2) One with 200 invitations

    Each vendor has a different price for the two packages. You’ll ask the user to input these two prices, as well as the total number of invitations that need to be sent out. Your job will be to calculate how many of each package to buy for the best deal, and how much will be spent on invitations.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    This is very similar to your steak and chicken dinner problem from this thread: Help Needed On A Program.

    Did you not read the homework policy then? Did you not learn anything from all the help you got? How about you reread that thread, and the thread Adak linked you in post #18 on that thread, and take another stab at it -- a serious one this time. I'm not getting the impression you like to do work for yourself.

    If you don't know how if statements and while loops work, check out our tutorials and Google some more tutorials. Find a good book and read it.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    there is 3 part to this assignment, I have done 2 parts, its just this one, I can't seem to get the equations right.

    are the equations I used right? I know there are more steps but are they right.

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Perspolice1993 View Post
    there is 3 part to this assignment, I have done 2 parts, its just this one, I can't seem to get the equations right.

    are the equations I used right? I know there are more steps but are they right.
    This is a simple min/max problem. I would suggest you google how to solve these mathematically so you understand what the process is, prior to attempting to code a solution. Until you know how to do it on paper, you will never be able to program it.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Perspolice1993 View Post
    there is 3 part to this assignment, I have done 2 parts, its just this one, I can't seem to get the equations right.
    I don't care if you already did the other two parts. This is the part you have questions on, this is the part you must show serious effort and initiative on if you want serious help.
    are the equations I used right? I know there are more steps but are they right.
    Nobody knows if your equation is right because we can't read your mind and you didn't tell us what a and b represent. You aren't thinking about your problem and you aren't trying much on your own. You came up with one equation, and ran here to ask us if you're right. Did you plug in some numbers and see what you get? Do those answers make sense? Your previous assignment had a sample run of the program that you could use to check if you are right. How about this assignment? Does it have any sample runs? Did you plug in those numbers and check?

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    I did work on it for 2 hours.
    Last edited by Perspolice1993; 09-22-2011 at 07:40 PM.

  7. #7
    Registered User
    Join Date
    Sep 2011
    Posts
    111
    Quote Originally Posted by Perspolice1993 View Post
    So don't post on this threat if you're gonna be a jerk. Just go to the beach and surf instead. Retard!!!
    It is not smart to bite the hand of and/or insult members of the board. It is a sure way to get your thread locked, and I am 100% sure there are rules about reopening locked threads will result in something you will not like.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is a pretty simple problem:

    1) One with 50 invitations
    2) One with 200 invitations

    Unless the one with 50 is less than 1/4th the price of the one with 200, you should use the 200 one as often as you can. The rest is just basic division.


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    sorry if I insulted, its just that moment I was somewhat ........ed cuz he was being a smart butt. But quzah I did come up with that conclusion, but I thought it was wrong for some reason. because I was gonna do if statement in that situation.

    I don't know I was probably over thinking it.

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Edit: Quzah has beat me to it.

    Calm down Perspolice, please. Edit your post of the name calling, right away, OK?

    Your problem is just another exercise in using the "solving two unknowns, by solving first for one unknown, in terms of the other one, and then solving the whole thing".

    I think of this as an algebra problem, but if you are good at arithmetic, it can be solved that way, as well. I prefer algebra, but my C code, prefers arithmetic.

    Why don't you post up the exact assignment you're working on, because that will help make it clearer to me. I read your first post, but the parameters of the problem just weren't clear to me, from that.

    So, I might be wrong, but it sure sounds like a repeat of the same type of problem as the Steak and Chicken Dinner problem. But post up the assignment word for word, and let's see if it is.

    And what the right equation(s) would be, if possible.
    Last edited by Adak; 09-22-2011 at 07:32 PM.

  11. #11
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    hey adak here is the url, is there anyway we can chat about this somewhere else, like on an instant messaging program. Do you have skype? if you do add me JayHakimi1, I will be on

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Perspolice1993 View Post
    there is 3 part to this assignment, I have done 2 parts, its just this one, I can't seem to get the equations right.

    are the equations I used right? I know there are more steps but are they right.
    If problems this simple are giving you fits of temper and stressing you to no end what are you going to do when the really hard stuff comes along?

    Tell ya what... people here volunteer their time to help people with problems in C program code.

    We're not here to teach you math or train you in problem solving.
    Last edited by CommonTater; 09-22-2011 at 08:10 PM.

  13. #13
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    then my question is if you're not here to help people in problem solving, then what is the point of this site?

  14. #14
    Registered User
    Join Date
    Sep 2011
    Posts
    111
    Quote Originally Posted by Perspolice1993 View Post
    then my question is if you're not here to help people in problem solving, then what is the point of this site?
    This site is to help programmers with questions about programming. As in strlen() is returning a size of 3 but I obviously have 6 things in there and here is my code.

    The problem you are having is, you need to pull out the pen and paper and SOLVE the problem using math.

    A IF statement evaluates if something is TRUE or FALSE, if the statement is true then do X code, else do Y code. Example if you come to a price you cannot do it can look like

    Code:
    if (price <= 500) //buy box1
    else //buy box 2




    Quote Originally Posted by CommonTater View Post
    If problems this simple are giving you fits of temper and stressing you to no end what are you going to do when the really hard stuff comes along?

    Tell ya what... people here volunteer their time to help people with problems in C program code.

    We're not here to teach you math or train you in problem solving.
    You know, I wish I was doing the write this function to solve this math problem...

    Buuut noo I get to play with malloc, the meat and bones of C
    Last edited by Strahd; 09-22-2011 at 08:35 PM.

  15. #15
    Registered User
    Join Date
    Sep 2011
    Posts
    72
    We help in C and C++ not math, thats not to say we wont help you, we will if need be, but the site is not for it.
    there are plenty of good sites for that
    Khan Academy if you don't know what to do.
    and if you need a forum just Google math forums.
    Last edited by Shawn Belcher; 09-22-2011 at 08:29 PM.
    English is my first language, I'm just not any good at typing\writing it, I can read and speak it just fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Convert Equations
    By SolarFlea in forum C++ Programming
    Replies: 6
    Last Post: 02-13-2010, 10:36 PM
  2. equations
    By shuo in forum C++ Programming
    Replies: 1
    Last Post: 05-02-2007, 08:47 PM
  3. Differential Equations - I need Help
    By KneeGrow in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-28-2004, 11:30 PM
  4. Math equations
    By C-Struggler in forum C Programming
    Replies: 6
    Last Post: 04-05-2003, 08:21 AM
  5. equations for a program
    By anthonye in forum C Programming
    Replies: 4
    Last Post: 06-19-2002, 04:38 AM