Thread: Help Needed On A Program

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    So, that's the source of the steak and chicken dinner problem I've been reading about!

    To get this off to a flying start, pick one program you think is easiest, and make up pseudo code and a skeleton program for it, and post it. Be sure to mention what has you stopped from going on. Look for the logical steps you would make, if you were to solve this without a computer.

    Our mind-reading skills are over-rated, I assure you, so the more specific your questions are, the better the answers you'll receive.

    Get started ASAP, because programming in C can take longer than you'd think.

  2. #17
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Adak View Post
    Get started ASAP, because programming in C can take longer than you'd think.
    I can programming in C real fast; it is getting the program to do what I want that takes so much time.

    In other words, testing the program takes a long time for me to do.
    I can fix it rather quickly; but, this is after using a C-Like language that caused me to pick up very bad habits.

    Hint: On writing programs, try writing the output code first using literals/constants for the user inputs.
    The output code is almost always easier to write than the input code.

    Tim S.

  3. #18
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Your wedding reception dinner problem may be the same as the problem in this thread:
    How to do a math equation in c Programming

    If not, it's very close. Especially, check out my thread dated today. That has the arithmetic you need (at least one version of it, there undoubtedly are others), to solve the number of maximum steak dinners, using C.

    The algebra equations at the top of that post are just for understanding. Go to near the end to see the other (C type) equation you may be able to use.

  4. #19
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by Strahd View Post
    The book we are using in my class is: The C Programming Language 2nd ED. by Kernighan & Ritchie ISBN: 0-13-110362-8.
    Don't get me wrong, that book is great for reference but poor for teaching and understanding C.
    I recommend: Teach Yourself C, Third Edition by Herbert Schildt

    I've read the Greek-translated version and it's very good! Anyway, just a suggestion.
    Devoted my life to programming...

  5. #20
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Sipher View Post
    Don't get me wrong, that book is great for reference but poor for teaching and understanding C.
    I recommend: Teach Yourself C, Third Edition by Herbert Schildt

    I've read the Greek-translated version and it's very good! Anyway, just a suggestion.
    I can only assume that's the same Herbert Schildt of bullschildt fame. I sincerely hope it doesn't suffer the same egregious errors as C: The Complete Reference (or C: The Complete Nonsense). Maybe check out our book recommendations sticky thread for other suggestions.

  6. #21
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Perspolice1993 View Post
    I have read the Homework policy. I was just asking for help to try to explain this to me, I don't want you to do the assignment. I hope you get what I'm trying to say.
    Ok... look at the problem logically... you have a 50 x 30 foot room ... each table is 4 x 8 with 3 feet between them...

    So... you are working with areas 7 feet by 11 feet for each table... now, how many can you fit along each wall?

    On the 50 foot wall you can get 4 (50/11) tables the long way or 7 (50/7) tables the short way.
    On the 30 foot wall you can get 2 (30/11) tables the long way or 4 (30/7) tables the short way.

    so...
    Placing the tables the long way of the room you end up with 4 by 4 = 16 tables
    Placing them the short way you get 7 by 2 = 14 tables.

    Now was that so hard?
    Last edited by CommonTater; 09-09-2011 at 10:35 AM.

  7. #22
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by anduril462 View Post
    I can only assume that's the same Herbert Schildt of bullschildt fame. I sincerely hope it doesn't suffer the same egregious errors as C: The Complete Reference (or C: The Complete Nonsense). Maybe check out our book recommendations sticky thread for other suggestions.
    Well, I don't know... Maybe our Greek translators were smarter than him!
    Devoted my life to programming...

  8. #23
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Sipher View Post
    Well, I don't know... Maybe our Greek translators were smarter than him!
    Or, in all due respect... perhaps it's time for a review...

    Seeing such doubt cast upon a trusted source would send me off to verify my understanding of the disputed concepts...

  9. #24
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Seeing such doubt cast upon a trusted source would send me off to verify my understanding of the disputed concepts...
    What did a ..... man once say?

    Bush "Fool Me Once..." - YouTube

    I couldn't bring myself to use the word 'wise' in that sentence.


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

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    ROFL... it doesn't get any better than that!

  11. #26
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    Hey CommonTater, thanks for the help, but do I need to show the calculation in my coding? if yes, I did this coding, I know it's long and there's a better way to make it shorter, but it won't let me run it cuz i get an error in line 55, can you please tell me if this is what I'm supposed to do and tell me what might possibly be the error.

    Code:
    // Jay Hakimi
    // COP 3223 Section 4
    // Programming Assignment #1
    // A Program to help Arup make decisions concerning his wedding
    
    #include <stdio.h>
    
    int main (void)
    
    {
    
        int length_of_room, width_of_room;
        int length_of_table, width_of_table;
        int space_walls_tables;
        int people_per_table;
        int max_people;
        int nlength_table, nwidth_table;
        int num_table1, num_table2, num_table3, num_table4;
        int max_table1, max_table2;
        int max_people1, max_people2;
    
        length_of_room = 50;
        width_of_room = 30;
        length_of_table = 8;
        width_of_table = 4;
        space_walls_tables = 3;
        people_per_table = 10;
        nlength_table = space_walls_tables+length_of_table;
        nwidth_table = space_walls_tables+nwidth_table;
    
        num_table1 = length_of_room/nlength_table;
        num_table2 = length_of_room/nwidth_table;
        num_table3 = width_of_room/nlength_table;
        num_table4 = width_of_room/nwidth_table;
    
        max_table1 = num_table1*num_table4;
        max_table2 = num_table2*num_table3;
    
        max_people1 = max_table1*people_per_table;
        max_people2 = max_table2*people_per_table;
    
        printf ("What are the length and width of the room?\n");
        printf ("%d feet by %d feet\n\n", length_of_room, width_of_room);
    
        printf ("What are the length and width of each table?\n");
        printf ("%d feet %d feet \n\n", length_of_table, width_of_table);
    
        printf ("How much space is required between each table?\n");
        printf ("%d feet\n\n", space_walls_tables);
    
        printf ("What is the max number of people per table?\n");
        printf ("%d People\n\n", people_per_table);
    
        if (max_people1 > max_people2)
            printf ("This arrangment seats %d people\n", max_poeple1);   <----------------- ERROR
        else
            printf ("This arrangment seats %d people\n", max_people2);
    
        return 0;
    
    }

  12. #27
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you got an error, then surely you would say what it was. (Granted it's not going to come out and say "you misspelled your variable name", but it'll be awfully close.)

  13. #28
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    it says max_people1 undeclared

  14. #29
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Perspolice1993 View Post
    it says max_people1 undeclared
    No it doesn't .
    Pay close attention to the exact spelling in that error message. The 'o' comes after the 'e'.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  15. #30
    Registered User
    Join Date
    Sep 2011
    Posts
    56
    Ok now error is fixed, but it gives me 0 when i say "this arrangement holds x seats"

    are my formulas wrong?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Program solution needed...
    By vijay.neo in forum C Programming
    Replies: 6
    Last Post: 10-18-2006, 11:12 PM
  2. Some help needed with program.
    By ajdspud in forum C++ Programming
    Replies: 2
    Last Post: 12-06-2005, 03:36 PM
  3. Help needed with program.
    By ajdspud in forum C++ Programming
    Replies: 6
    Last Post: 11-22-2005, 04:05 PM
  4. Program crashes...help Needed!!
    By butterfly in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2002, 11:22 AM
  5. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM

Tags for this Thread