3
Reply

Need help with problem please...

Ask a question
Phil Jagielski

Phil Jagielski

14 years ago
1.9k
1
I got this far in my problem with class, but now it wants me to switch it.  Where the code outputs the program with the percentages (5%, 10%, 15%)  on top and the years (10, 20, 30, and 40) on the side with the amount in each spot, I now have to switch it and have the years on top and the percentages on the side, but can't figure out how to go about this, I've tried a bunch of stuff and still come up with the same thing.  Any help would be appreciated, or if you can just point me in the right direction and tell me what I need to do to switch it, I would aprreciate it.  Every time I try to it ends up with the stuff in the right places, but the totals that are supposed to be in their spots aren't there anymore.


using System;
using System.Collections.Generic;
using System.Text;

namespace lab3a
{
    class Program
    {
        static void Main(string[] ags)
        {
            Console.Write("Please input your name: ");
            string employeeName = Console.ReadLine();

            Console.Write("Please input your salary: ");
            string inputSalary = Console.ReadLine();
            double salary = int.Parse(inputSalary);

            double balance5Percent = 0.0;
            double balance10Percent = 0.0;
            double balance15Percent = 0.0;

            Console.WriteLine();
            Console.WriteLine("{0} at your current salary of {1:C} these are your expected balances", employeeName, salary);
            Console.WriteLine();
            Console.WriteLine("                    5%              10%              15%");
            Console.WriteLine("=========================================================");
            for (int i = 1; i <= 40; i++)
            {
                balance5Percent = (salary * 0.05 + balance5Percent) * 1.08;
                balance10Percent = (salary * 0.10 + balance10Percent) * 1.08;
                balance15Percent = (salary * 0.15 + balance15Percent) * 1.08;

                if (i % 10 == 0)
                {
                    Console.WriteLine(" Year {0}   {1,14:C}  {2,14:f}  {3,14:C}", i, balance5Percent, balance10Percent, balance15Percent);
                }
            }
            Console.WriteLine("=========================================================");
            Console.ReadLine();
        }
    }
}

Answers (3)