| noo1 (59) | |||
|
I am soooo lost. Please help me. I have to write a program which uses an inline function calculateStockValue. the function takes two parameters - one is a number of shares and the other is unit price of a share. User should be able to use this function as many times as he wants unless he wants to quit. (loop here???) Once user has completed entering data, the program should be able to provide a feedback to the user about his total account value (sum of all the values of the shares). It says I also have to write a test program (main function) to test the working of the code. There's so much of this I don't understand. So, for starters, how do I accumulate the stock shares and their related prices? Here's what I have so far...
| |||
|
|
|||
| Gulshan Singh (46) | |
| Yes, you would have the function call in a loop. To store the value, simply make a float variable outside of the loop initialized to 0, and the inside the loop whenever the function is called add the result to the variable. | |
|
|
|
| noo1 (59) | |||
|
Oh my goodness, thank you so much for replying!!! I have put in so much time on this and have no one to lead me in the right direction. So, I added a loop below and what I think is an exit for the loop. I'm still getting fail error. I know this code is messed up. Any advice is greatly appreciated.
1>------ Build started: Project: Lab4, Configuration: Debug Win32 ------ 1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup 1>C:\Users\fgower\Documents\Visual Studio 2010\Projects\Lab4\Debug\Lab4.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |||
|
Last edited on
|
|||
| noo1 (59) | |
|
Somehow or another, my source file wasn't part of the project. So I added it as a new item and now I'm getting different errors: 1>------ Build started: Project: Lab4, Configuration: Debug Win32 ------ 1> calculatedStockValue.cpp 1>c:\users\fgower\documents\visual studio 2010\projects\lab4\lab4\calculatedstockvalue.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\fgower\documents\visual studio 2010\projects\lab4\lab4\calculatedstockvalue.cpp(16): error C2144: syntax error : 'unsigned int' should be preceded by ';' 1>c:\users\fgower\documents\visual studio 2010\projects\lab4\lab4\calculatedstockvalue.cpp(31): error C2061: syntax error : identifier 'cout' 1>c:\users\fgower\documents\visual studio 2010\projects\lab4\lab4\calculatedstockvalue.cpp(32): error C2059: syntax error : ')' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |
|
|
|