A
Anil Gupte
I get two errors
void DisplayProjectedValue(double amount, int years)
{
Random __gc * r = new Random();
int randomRate = r->Next(0, 20);
DisplayProjectedValue(amount, years, randomRate);
}
void DisplayProjectedValue(double amount, int years, double rate)
{
double rateFraction = 1 + (rate/100);
double finalAmount = amount * Math:ow(rateFraction, years);
finalAmount = Math::Round(finalAmount, 2);
Console::WriteLine(S"--------------------------------------------");
Console::WriteLine(S"Investment Amount: ");
Console::Write(amount);
Console::WriteLine(S"Growth Rate [%]: ");
Console::Write(rate);
Console::WriteLine(S"Period [years]: ");
Console::Write(years);
Console::WriteLine (S"Projected Final value of Investment: ");
Console::Write(finalAmount);
Console::WriteLine(S"--------------------------------------------");
}
I tried changing the last line of the first function to:
DisplayProjectedValue(amount, years, randomRate->ToDouble(0));
but that also gave me errors.
This is from a book Visual C++ .Net by Templeman and Olsen (Microsoft
Press).
void DisplayProjectedValue(double amount, int years)
{
Random __gc * r = new Random();
int randomRate = r->Next(0, 20);
DisplayProjectedValue(amount, years, randomRate);
}
void DisplayProjectedValue(double amount, int years, double rate)
{
double rateFraction = 1 + (rate/100);
double finalAmount = amount * Math:ow(rateFraction, years);
finalAmount = Math::Round(finalAmount, 2);
Console::WriteLine(S"--------------------------------------------");
Console::WriteLine(S"Investment Amount: ");
Console::Write(amount);
Console::WriteLine(S"Growth Rate [%]: ");
Console::Write(rate);
Console::WriteLine(S"Period [years]: ");
Console::Write(years);
Console::WriteLine (S"Projected Final value of Investment: ");
Console::Write(finalAmount);
Console::WriteLine(S"--------------------------------------------");
}
I tried changing the last line of the first function to:
DisplayProjectedValue(amount, years, randomRate->ToDouble(0));
but that also gave me errors.
This is from a book Visual C++ .Net by Templeman and Olsen (Microsoft
Press).