### Using Default Initialization / Inflation Rate

Hello!

I am creating a program that will calculate the amount of mortgage we paid for a property over a certain amount of time, also while at it, I gave an option to calculate the value of the property over a certain period of time as well.

The second part to this program is to calculate the amount of money your investment will rise if you put it into the stock market @ a certain return value.

Majority of the program are user inputs to solve the equation, but my concern is; what if I wanted to have the default initialization be run through instead of asking the user all the questions? I already have an if, if else, and else for menu selections. Should I add a seperate section just for it to run through with the exact value I want it to, and not the users or is there another way we can use the original initialization without creating another function just for the new selection in the menu? If there isn't a way then I wouldn't mind creating one, it isnt hard, but since I am learning how to code, I want to learn all the methods.

Also, my 2nd question is about inflation over time for rent. I ask the user what is the current average annual inflation rate for rental, and I want it to compound it but also add the previous amount to have the actual amount. What I mean is: My first year consist of \$500 a month rental x a 12 (year) to get \$6000. Average inflation rate is about %4. So I paid about \$6000 my first year, \$6240 my 2nd year, and finally \$6489.6 my 3rd. Without creating a loop, is there any way I can calculate it so it will compound the amount through, lets say, 30 years and add all of it together in order to get a final amount spent on rent?

Here is my current code:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354`` ``````float savings, investment, rate, time, accum, year, rent, inflation; float exp, par, solution; cout << endl << "You have chosen Stock Investment option #1" << endl << endl; cout << "How much money do you have in your savings to invest?: "; cin >> savings; cout << endl << "How much of your savings will you invest your money into Stocks?: "; cin >> investment; if (investment<=savings) { cout << endl << "Enter the average return for the Stock Market (percentage): "; cin >> rate; rate = (rate/100); cout << endl << "Enter the amount of year/s that you are planning to keep your money invested in the Stock Market: "; cin >> time; par = (1+rate); exp = pow(par,time); solution = investment * exp; cout << endl << setprecision (2) << fixed<< "In " << time << " years, you will have accumulated \$" << solution << " through your investment to the stock market." << endl << endl; cout << "As you spent most of your savings in Stocks, you will also need to calculate how much you will be spending on your rent." << endl << endl; cout << "How much is your current rent per month?: "; cin >> rent; rent = rent * 12; //This is the total amount in 12 months, or a year. cout << endl << "This rental price will not always stay the same." << endl << endl << "Please enter the average inflation rate on rent (percentage): "; cin >> inflation; inflation = inflation / 100; //This inflation rate is the rate that the price of rental will go up ever year, and I will divide it by 100 to get a decimal. par = (1+(inflation)); exp = pow(par,time); solution = rent * exp; cout << endl << "To make sure you will have enough to pay for rent, you will need \$" << solution; cout << endl <<" in order to have a roof over your head until the end of your investment." << endl << endl; system("Pause");``````

Please see if you can help me with this! Thank you very much, and sorry I wrote so much.

Topic archived. No new replies allowed.