This is a Console (.NET) program
CODE
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
void DisplayWelcome();
void DisplayProjectedValue(double amount, int years, double rate);
double GetInvestmentAmount();
int GetInvestmentPeriod(int min = 10, int max = 25);
void DisplayWelcome()
{
Console::WriteLine(S"\n\n\no------------------------------o");
Console::WriteLine(
S" Welcome to Investment Planner!");
Console::WriteLine(S"o------------------------------o");
return;
}
void DisplayProjectedValue(double amount, int years, double rate)
{
double rateFraction = 1 + (rate/100);
double finalAmount = amount * Math::Pow(rateFraction, years);
finalAmount = Math::Round(finalAmount, 2);
Console::Write(S"Investment amount: ");
Console::WriteLine(amount);
Console::Write(S"Growth rate [%] ");
Console::WriteLine(rate);
Console::Write(S"Period [years]: ");
Console::WriteLine(years);
Console::Write(S"Projected final value of investment: ");
Console::WriteLine(finalAmount);
return;
}
double GetInvestmentAmount()
{
Console::Write(S"How much money do you want to invest? ");
String __gc * input = Console::ReadLine();
double amount = input->ToDouble(0);
return amount;
}
int GetInvestmentPeriod(int min, int max)
{
Console::Write(S"Over how many years [");
Console::Write(S"min = ");
Console::Write(min);
Console::Write(S", max = ");
Console::Write(max);
Console::Write(S"] ? ");
String __gc * input = Console::ReadLine();
int years = input->ToInt32(0);
return years;
}
int _tmain()
{
DisplayWelcome();
Console::WriteLine(S"\nIllustration...");
DisplayProjectedValue(10000, 25, 6.0);
Console::WriteLine(S"\nEnter details for your investment:");
double sum = GetInvestmentAmount();
int period = GetInvestmentPeriod(5, 25);
Console::WriteLine(S"\nYour plan...");
DisplayProjectedValue(sum, period, 6.0);
_tmain();
return 0;
}