Help with a project  
Author Message
Hybrid Bray der Burrito

PostPosted: Visual C++ General, Help with a project Top

I'm currently taking a C++ class, and we just learned about if, else and else if. What we were told to do was make a program that
"Create a program that asks the user five math problems. You can make them as simple or as difficult as you want. Give the user a chance to type in the answer and calculate whether or not they got it right or wrong."
and also
"Praise them for a correct answer, but be gentle when they get it wrong. If they got it wrong, then supply them with the correct answer. After they have been asked five questions, print out the total number of correct answers."
and to do that we should
"Ask the questions in your main function, but use a single secondary function to get their response, see if they are correct and print out the response. Your function should return a value that will let the main function know if they got it right."

I'm not quite sure how to do that with the knowledge (or lack thereof) that I currently have. I do not want someone to just give me the code, but rather I would like some hints and tips on how I might do this.

Thanks for any and all help.

Visual C++1  
Simple Samples

PostPosted: Visual C++ General, Help with a project Top

This is something that is explained in many books and such. Volunteers in forums such as this usually avoid answering questions such as this because there are so many great answers that already exist.

There are many techniques for designing programs. One is to use pseudo-code, which is nothing standard or well defined. Pseudo-code can be anything you want it to be if you are the only person using it. You can use pseudo-code to write a generalized draft version of your program. You can use whatever terminology you understand. Start by describing what you need to do at the topmost level which in this case is the main function. For example you might have:

Do 5 times
	ask for math problem
	if correct
		praise them
		say it is incorrect

Note that I have left out a couple of things, but that is just an example. After doing the top level as above, do each item (function) that needs more detail. Do that for each lower item. Then when you are ready, convert the pseudo-code to valid C++ code. By doing this (using pseudo-code) you can separate the overall program into peices that are easier to work with. You can use diagrams instead of narrative text if that helps you.

Hybrid Bray der Burrito

PostPosted: Visual C++ General, Help with a project Top

Ok, I think I get what you're saying. Thanks for actually taking the time to help me out!