You are viewing an obsolete version of the DU website which is no longer supported by the Administrators. Visit The New DU.
Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

Reply #9: I don't know if I can help [View All]

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
TabulaRasa Donating Member (223 posts) Send PM | Profile | Ignore Mon Dec-04-06 11:40 PM
Response to Reply #2
9. I don't know if I can help
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
Printer Friendly | Permalink |  | Top
 

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC