Use methods to input the principle, interest rate, and number or years to invest some
money. Program will consist of the following methods.

GetInvestment()
This method will input a double value for the princple, and a double value for the interest rate. All Values are input without error checking. All Values are returned to main as out parameters.

GetYears()
This method inputs the number of years for the investment as an integer value. The value will be checked to ensure that it is valid integer, and within the range of 5 to 15 years(inclusive). A loop will be used to ensure that the value meets these specifications. Return the value to the main program.

ShowGrowth()
This method calculates the value of the investment for each year, and displays the results as shown below. A For loop will be used to display the values. The method will be passed all values that are required. Note that the new principle for each year is old principle plus the interest times the old principle.

The Output should be.

Investment Calculator

Enter principle value: 1000
Enter interest rate: 10
Number of years: 4
Number of years is out of range.
Number of years: 16
Number of years is out of range.
Number of years: yuck
An invalid number was entered.
Number of years: 10

Year 1, Value = $1,100.00
Year 2, Value = $1,210.00
Year 3, Value = $1,331.00
Year 4, Value = $1,464.10
Year 5, Value = $1,610.51
Year 6, Value = $1,771.56
Year 7, Value = $1,948.72
Year 8, Value = $2,143.59
Year 9, Value = $2,357.95
Year 10, Value = $2,593.74

Could you guys help me...
My code works, but my professor wont accept it...

static void Main(string[] args)
        {
            Console.Clear();

            Console.Title = "Investment Calculator";

            Console.WriteLine("{0, 40}", "Investment Calculator");

            double dvalue;
            double dRate;       

            GetInvestment(out dvalue, "Enter principle value: ");
               
            GetInvestment(out dRate, "Enter interest rate: ");

            int iyears = GetYears("Number of years: ", 5, 15);

            double dResult = ShowGrowth(dvalue, dRate, iyears);

            Console.ReadLine();
        }
        static public void GetInvestment(out double dvalue, string sPrompt)
        {
            bool bError;
            dvalue = 0.0;

            do
            {
                try
                {
                    bError = false;
                    Console.Write("\n{0}", sPrompt);
                    dvalue = double.Parse(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.Write("An invalid number was entered. Please try again.");
                    bError = true;
                }
            }
            while (bError);
            return;
        }
        static int GetYears(string sPrompt, int imin, int imax)
        {
            int iValue = 0;
            bool bError;

            do
            {
                try
                {
                    bError = false;
                    Console.Write(sPrompt);
                    iValue = int.Parse(Console.ReadLine());

                    if ((iValue < imin) || (iValue > imax))
                    {
                        Console.WriteLine("The Value entered is out of range");
                        bError = true;
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("Number of years is out of range.");
                    bError = true;
                }
                finally
                {
                    Console.WriteLine("");
                }
            }
            while (bError);
            return iValue;
        }
        static double ShowGrowth(double dn, double dr, int iy)
        {
            double dAnswer = dn;
            double factor = (100.0 + dr)/100.0;
 
            for (int i = 1; i <= iy; i++)
            {
                dAnswer *= factor;
                Console.WriteLine("Year {0}, Value = {1:C}", i, dAnswer);
            }
            return dAnswer;
        }

You need to reread the requirements. Just looking at the first method you didn't implement what they asked. It should have two out parameters only, it doesn't do error checking. You've provided one out parameter and some other parameter that it didn't ask for. You only get one value in the method and it asks you to get two. You do error checking when it told you not to do so.

This article has been dead for over six months. Start a new discussion instead.