Guru3D.com Forums

Go Back   Guru3D.com Forums > General > Programming/Html
Programming/Html C++,Visual Basic,HTML,Flash,OpenGL,Modelling,Java.



Reply
 
Thread Tools Display Modes
Need Help my fellow GURU's
Old
  (#1)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default Need Help my fellow GURU's - 07-02-2015, 13:53 | posts: 52

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.
   
Reply With Quote
 
Old
  (#2)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-03-2015, 13:44 | posts: 3,509 | Location: Moscow, Russia

Pure C? Or C++?
   
Reply With Quote
Old
  (#3)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-03-2015, 21:21 | posts: 52

Pure C. Here is the link. Thanks for the reply.

Last edited by rakee18; 07-13-2015 at 23:20.
   
Reply With Quote
Old
  (#4)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-04-2015, 02:16 | posts: 52

If someone could put me on the right direction I could start.
   
Reply With Quote
 
Old
  (#5)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-06-2015, 22:25 | posts: 3,509 | Location: Moscow, Russia

Quote:
This assignment requires you to modularize your program, in order to reduce redundancy in your code and to enhance its readability. Significant marks will be reserved by your instructor for judging the quality of how well you divide your program
logic into functions. You are also expected to comment your program code - consult your instructor to find out the nature of in-code documentation required.
Your code should ask user for 3 input values:
Quote:
1. The size of the container (1 to 8 ONLY) (MUST BE VALIDATED),
2. The level of nutrients in the growth medium (0 to 3 ONLY) (MUST BE VALIDATED), and
3. The temperature to grow the bacteria in Celsius (20 to 54 ONLY) (MUST BE VALIDATED).
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 by mbk1969; 07-06-2015 at 22:34.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
Copyright (c) 2017, All Rights Reserved. The Guru of 3D, the Hardware Guru, and 3D Guru are trademarks owned by Hilbert Hagedoorn.