Here is in C++ Passing user input to a variable to a parameter for a function in. But I need pass parameters from user for constructor parameters. Please help me with simple example. Don't have to be same as mine, you can do all different but I just need it.
#include <iostream>
#include <cmath>
using namespace std;
float stockMarketCalculator(float p, float r, int t){
float a;
for(int day = 1; day <=t; day++){
a = p * pow(1+r, day);
cout << a << endl;
}
}
int main()
{
float p;
float r;
int t;
cout << "Please enter the principle" << endl;
cin >> p >> endl;
cout << "Please enter the rate" << endl;
cin >> r >> endl;
cout << "Please enter the time in days" << endl;
cin >> t >> endl;
cout << stockMarketCalculator(p, r, t);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire