Thread: Simple Assignment, Can't Figure Out the Calculation

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    21

    Simple Assignment, Can't Figure Out the Calculation

    Code:
    #include <stdio.h>
    
    
    int main(int argc, const char * argv[])
    {
    
    
        int stud_num, section, std_section, last_section;
        float cost_factor;
        
    /* Get input from user */
        
        printf("Enter the number of students:");
        scanf("%d", &stud_num);
        
    /* Calculations */
        
        section = stud_num/35;
        
        std_section =
        
        last_section =
        
        cost_factor = (35*section)/stud_num;
        
        
    
    
        return 0;
    }
    That's my code so far.

    I'm not sure what the prof is asking for in the standard section and the last section? And I can't even think of how to calculate it.

    Here is the assignment page: C code - 35 lines - codepad
    Last edited by iamtazb; 09-30-2012 at 07:06 PM.

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    I'm not sure what the prof is asking for in the standard section and the last section?
    Ask your professor for clarification - Talking to your professor is always a good idea; they might hint towards a solution that they are looking for.

    And I can't even think of how to calculate it.
    You need to sit down with a pen and a piece of paper and find a way that you can calculate it before writing any code.
    Fact - Beethoven wrote his first symphony in C

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    21
    Quote Originally Posted by Click_here View Post
    Ask your professor for clarification - Talking to your professor is always a good idea; they might hint towards a solution that they are looking for.



    You need to sit down with a pen and a piece of paper and find a way that you can calculate it before writing any code.
    There is what my paper looks like:

    imgur: the simple image sharer

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    What did your professor say when you asked for clarification?
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User
    Join Date
    May 2012
    Posts
    21
    Quote Originally Posted by Click_here View Post
    What did your professor say when you asked for clarification?
    I'm not sure, I'm guessing counting sheeps.

    It's pretty late bud.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    The entire assignment: https://scs.senecac.on.ca/~ipc144/ip...3/assign1.html

    In your program's source code (added as /* comments */) you must
    include the following Seneca College Student Oath:
    Oath:

    Student Assignment Submission Form
    ==================================
    I declare that the attached assignment is wholly my
    own work in accordance with Seneca Academic Policy. No part of this
    assignment has been copied manually or electronically from any
    other source (including web sites) or distributed to other students.
    That really indicates you should be addressing your lack of understanding of the assignment with the professor, as noted above, rather than coming here.

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by iamtazb View Post
    I'm not sure what the prof is asking for in the standard section and the last section? And I can't even think of how to calculate it.
    You have to solve the following problem:
    The school wants to split all students to sections of nearly the same size (where the maximum size is 35 students for a section).
    Standard section means the size of a full section, last section means the size of the remaining section.

    Look at the examples you have been given:
    If there are 350 students you end up with 10 sections of 35 students each (350 / 35 = 10). Thus the size of a standard section and the size of the last section is the same (35).

    Now consider the case of 351 students. You need 11 sections to accomodate all students (351 / 35 = 10,029 -> 10 full (= standard) sections and 1 for the remaining students). If you would fill up the first 10 sections to the maximum (standard section = 35) the last section would contain only one student (35 * 10 = 350 -> 351 - 350 = 1). But that's not what the school wants. They want that the difference of the size of a standard section and the size of the last section is as small as possible. You should come up with an algorithm which solves this optimization problem.

    HTH, Andreas

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    As it's the first assignment, it's actually pretty ambitious. From the assignment:

    (The derivation of these numbers will be discussed in class).
    Has that happened yet? It should make things clearer for you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Programming Assignment Help!! (Cant Figure Out My Errors) :(
    By irishfeeney92 in forum C Programming
    Replies: 19
    Last Post: 04-28-2011, 02:14 PM
  2. simple calculation of division
    By steve1_rm in forum C Programming
    Replies: 2
    Last Post: 09-13-2008, 05:37 AM
  3. Simple calculation not working, need help
    By Summonerur in forum C Programming
    Replies: 20
    Last Post: 09-24-2004, 02:53 PM
  4. Repeating a simple calculation
    By FloatingPoint in forum C++ Programming
    Replies: 2
    Last Post: 07-21-2003, 07:33 AM
  5. Replies: 0
    Last Post: 04-22-2002, 11:33 PM