|
without actually doing it for him. Also, it's been a while since I've programmed (took a few courses in college), so alot of the specifics aren't there. But I'll try.
These are fairly straight-forward questions. For each of the problems there are only a few things that need to be done. First, each of the two programs needs certain introductory instructions that allow the program to run. I don't remember exactly what they are, but having a sample program in C++ will help. You just need to copy these into the program letter for letter. The most important one is that he needs to set up a "main" function, in which all the program instructions are written. Again, consult a sample to see what this looks like: "int main () { <program body> } ", or some such thing. I'll just tell the steps for the second problem, because the steps are essentially the same for both (only the mathematical formula needs to be changed). First, you need to set aside memory locations to store all the data you input. This is known as declaring variables, which must be of certain numeric types (integer, decimal, etc.) So for the second problem, you create a variable for the input dollar amount ... something like this: "float dollarAmount;" The first word is the type, which is floating point, or decimal. The second word is the variable name, which you can pick to be essentially whatever you want. This is the program's name for the memory location where the dollar amount can be stored. Then the program has to prompt the user for the dollar amount. There is a specific syntax to do this; I just don't remember what it is. Again, use a sample. Basically, the instructions are "cout" (for text output to the user) and "cin" for text input from the user. Something like this instruction stores the input value from the user in the dollarAmount variable: "cin >> dollarAmount", I think. Then an instruction must compute the appropriate foreign currency ... something like this "Yen = dollarAmount * 104.8" This multiplies the dollar amount by the exchange rate to get the new currency. It also stores that value in a variable called "Yen", which must be declared along with "dollarAmount". Then you output this value using the cout function. And you're done, at least with the Yen part. I hope this helps. If your son is still confused, send me a PM, and we'll see what we can work out. :D
|