Need Help my fellow GURU's

Discussion in 'Programming/Html' started by rakee18, Jul 2, 2015.

  1. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    I'm trying to figure out where to start my school assignment. I could post it if someone is willing to help me out. I would really appreciate it. Its in C language. I have to make a function about some bacterial growth.
     
  2. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,604
    Likes Received:
    13,613
    GPU:
    GF RTX 4070
    Pure C? Or C++?
     
  3. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Pure C. Here is the link. Thanks for the reply.
     
    Last edited: Jul 14, 2015
  4. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    If someone could put me on the right direction I could start.
     

  5. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,604
    Likes Received:
    13,613
    GPU:
    GF RTX 4070
    Your code should ask user for 3 input values:
    One of the approach to the coding is to write down all the lines of the task into the source code as the comments.
    Code:
    void main(int argc, char* argv)
    {
    // 1. Ask the user for the size of the container (1 to 8 ONLY) (MUST BE VALIDATED)
    // 2. Ask the user for the level of nutrients in the growth medium (0 to 3 ONLY) (MUST BE VALIDATED)
    // 3. Ask the user for the temperature to grow the bacteria in Celsius (20 to 54 ONLY) (MUST BE VALIDATED).
    }
    And then start to dive into each line:
    Code:
    void main(int argc, char* argv)
    {
    // 1. Ask the user for the size of the container (1 to 8 ONLY) (MUST BE VALIDATED)
    // 1.1. Print the line which will ask the user to enter the size of the container
    // 1.2. Read the line of the user`s input
    // 1.3. Convert the line into the number
    // 1.4. Compare the number with given limits
    // 2. Ask the user for the level of nutrients in the growth medium (0 to 3 ONLY) (MUST BE VALIDATED)
    // 2.1. Print the line which will ask the user to enter the level of nutrients in the growth medium
    // 2.2. Read the line of the user`s input
    // 2.3. Convert the line into the number
    // 2.4. Compare the number with given limits
    // 3. Ask the user for the temperature to grow the bacteria in Celsius (20 to 54 ONLY) (MUST BE VALIDATED).
    // 3.1. Print the line which will ask the user to enter the temperature to grow the bacteria in Celsius
    // 3.2. Read the line of the user`s input
    // 3.3. Convert the line into the number
    // 3.4. Compare the number with given limits
    }
    You can see that steps 1,2,3 have the same actions - print the prompt, get the line from user, convert the line (string) to number, compare the number with limits - these actions are the candidates for 4 simple functions or one big function with 4 steps.
    Like:
    Code:
    int GetValueFromUser(char* prompt, int limitMin, int limitMax)
    {
    // 1. Print the prompt
    // 2. Read the line of the user`s input
    // 3. Convert the line into the number
    // 4. Compare the number with given limits limitMin and limitMax
    }
    
    void main(int argc, char* argv)
    {
    int containerSize;
    int nutrientsLevel;
    int temperature;
    // 1. Ask the user for the size of the container (1 to 8 ONLY) (MUST BE VALIDATED)
    containerSize = GetValueFromUser("Please enter the size of container (in feet)", 1, 8);
    
    // 2. Ask the user for the level of nutrients in the growth medium (0 to 3 ONLY) (MUST BE VALIDATED)
    nutrientsLevel = GetValueFromUser("Please enter the level of nutrients", 0, 3);
    
    // 3. Ask the user for the temperature to grow the bacteria in Celsius (20 to 54 ONLY) (MUST BE VALIDATED).
    temperature = GetValueFromUser("Please enter the temperature (in Celsius)", 20, 54);
    }
     
    Last edited: Jul 6, 2015

Share This Page