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.
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); }