The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
The Anything and Everything forum is still open.
can anyone figure this out?
|
|||
|
Rank: ? (11)
Member #: 21570 |
Ok, this code is driving me nuts. I have to use a function for calculating this assignment. Im not even done finishing writing the code, im not that good with functions but the code is pretty self explanatory. It just does a one of 2 calculations. I know im like only 5 mins away from completion. I just need help finishing it. Feel free to copy in text editor.
#include <iostream> #include <cmath> using namespace std; //Function Prototype double var( double, double, double, double ); int main() { int option; double princ, interest, years, compound; cout << "Enter a 1 to calculate a compound amount" << endl; cout << "Enter a 2 to calculate an amount compounded continuosly" << endl; cout << "Enter a 3 to exit the program" << endl; cin >> option; while (option < 1 || option > 3) { cout << "Error, please enter a 1, 2, or 3" << endl; cin >> option; } switch(option) { case 1: cout << "You selected compound amount" << endl; cout << "Please enter the principle, interest rate, years, and compounds per year" << endl; cin >> princ >> interest >> years >> compound; cout << "The amount compounded " << compound << " times a year at an interest rate of " << interest << " for " << years << " is $" << endl; break; case 2: cout << "You selected compound continuosly" << endl; cout << "Please enter the principle, interest rate, years" << endl; cin >> princ >> interest >> years; break; case 3: cout << "Thank you" << endl; return 0; } } double var( double princ, double interest, double years, double compound ) { double ans; ans = princ * pow( 1 + (interest/compound), (compound * years); return ans; } here is the error- cp5.C: In function `double var(double, double, double, double)': cp5.C:48: syntax error before `;' token deneb/nfs/user/z/zepol/cs151 > |
||
|
|||
|
|||
|
Rank: ? (11)
Member #: 21570 |
ok i got it now, so dont bother unless you want to know for yourself
|
||
|
Please login or register to post a reply.
