Okay, so I just realized I was doing half of what I wanted already..How do I pull just my interest gained on my savings account to print to console from main? Also is there a way to remove the part of my menu I have duplicated? Or a better way to do my menu? It just seems really messy.

class SavingsAccount : Account
    {
        private decimal interestrate;
        public SavingsAccount() { interestrate = 0.0m; }
        public decimal interest { get; private set; }



            public SavingsAccount(decimal balance, decimal rate)
                : base(balance)
            {
                interestrate = rate;
                //calculate interest when the saving account is created first time
                decimal interest = CalculateInterest();
                Credit(interest);
            }

            public decimal CalculateInterest()
            {
               interest = base.Balance * interestrate /100;
                return interest;
            }

        }
    }



        static void Main(string[] args)
        {

            List<decimal> transactions = new List<decimal>();
            List<decimal> transactionFees = new List<decimal>();
            List<string> transactionType = new List<string>();
            //Create the array of Acount
            Account[] MyAccount = new Account[2];
            //Initialize the saving account (interest is applied immediately to savings account)
            MyAccount[0] = new SavingsAccount(1500.00m, 5.5m);
            //Initialize the checking account
            MyAccount[1] = new CheckingAccount(1000.00m, 0.5m);
            string starTop = "*****************************";
            string starSide = "*";
            Console.WriteLine("SavingAccountBalance : $" + MyAccount[0].Balance.ToString());
            Console.WriteLine("CheckingAcount Balance : $" + MyAccount[1].Balance.ToString());
            //menu for checking acct
            int menuchoice = 0;
****take a look here please  SavingsAccount interest = new SavingsAccount();
                                    interest.CalculateInterest(MyAccount[1]); (i can't figure out how to call CalculateInterest)
            //menu for checking acct

            while (menuchoice != 3)
            {
                //excuse my messy formatting, this is the menu with stars...OoOoOoo.
                Console.Clear();
                Console.WriteLine(starTop + starTop);
                Console.WriteLine(starSide + " Bank Checking Account Menu                       " + starSide);
                Console.WriteLine(starTop + starTop);
                Console.WriteLine(starSide + " Please enter a selection according to number:          " + starSide);
                Console.WriteLine(starSide + " 1. Deposit                                             " + starSide);
                Console.WriteLine(starSide + " 2. Withdraw                                            " + starSide);
                Console.WriteLine(starTop + starTop);


                try
                {
                    menuchoice = int.Parse(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("This is not a valid selection!");
                }

                //cases for menu
                switch (menuchoice)
                {//Deposit case
                    case 1:

                        //menu for checking acct
                        int menuchoice1 = 0;
                        while (menuchoice1 != 3)
                        {
                            //excuse my messy formatting, this is the menu with stars...OoOoOoo.
                            Console.Clear();
                            Console.WriteLine(starTop + starTop);
                            Console.WriteLine(starSide + " Bank Account Menu                                " + starSide);
                            Console.WriteLine(starTop + starTop);
                            Console.WriteLine(starSide + " Please enter a selection according to number:          " + starSide);
                            Console.WriteLine(starSide + " 1. Savings Account                                     " + starSide);
                            Console.WriteLine(starSide + " 2. Checking Account                                    " + starSide);
                            Console.WriteLine(starSide + " 3. Exit                                                " + starSide);
                            Console.WriteLine(starTop + starTop);

                            try
                            {
                                menuchoice1 = int.Parse(Console.ReadLine());
                            }
                            catch (FormatException)
                            {
                                Console.WriteLine("This is not a valid selection!");
                            }

                            //cases for menu
                            switch (menuchoice1)
                            {//Savings Account Deposit Case
                                case 1:

                                    Console.WriteLine(" Please enter amount to deposit to savings account");
                                    decimal savingsCredit = Convert.ToDecimal(Console.ReadLine());
                                    MyAccount[0].Credit(savingsCredit);
                                    Console.WriteLine("Your balance is: {0:C}", MyAccount[0].Balance);
                                    Console.ReadLine();
                                    break;
                                //Checking Deposit Case
                                case 2:


                                    Console.WriteLine(" Please enter amount to deposit to checking account");
                                    decimal checkingCredit = Convert.ToDecimal(Console.ReadLine());
                                    MyAccount[1].Credit(checkingCredit);
                                    Console.WriteLine("New Balance is: {0}", MyAccount[1].Balance);
                                    Console.ReadLine();
                                    break;

                                case 3:
                                    break;
                            }

                        }
                        break;
                    //Withdrawal Case
                    case 2:

                        //menu for checking acct
                        int menuchoice2 = 0;
                        while (menuchoice2 != 3)
                        {

                            try
                            {
                                menuchoice2 = int.Parse(Console.ReadLine());
                            }
                            catch (FormatException)
                            {
                                Console.WriteLine("This is not a valid selection!");
                            }
                            //cases for menu
                            switch (menuchoice2)
                            {//Savings Account Withdrawal Case
                                case 1:

                                    Console.WriteLine(" Please enter amount to withdraw to savings account");
                                    decimal savingsDebit = Convert.ToDecimal(Console.ReadLine());
                                    MyAccount[0].Debit(savingsDebit);
                                    Console.WriteLine("Your balance is: {0:C}", MyAccount[0].Balance);
                                    Console.ReadLine();


                                    break;
                                //Checking Withdrawal Case
                                case 2:


                                    Console.WriteLine(" Please enter amount to withdraw to checking account");
                                    decimal checkingDebit = Convert.ToDecimal(Console.ReadLine());
                                    MyAccount[1].Debit(checkingDebit);
                                    Console.WriteLine("New Balance is: {0}", MyAccount[1].Balance);
                                    Console.ReadLine();
                                    break;

                                case 3:
                                    break;

                            }
                        }
                        break;
                }
            }
        }
    }
}

Edited 3 Years Ago by kiail

ignore line 47, I've removed it.

Edited 3 Years Ago by kiail

here's my account class, I guess that's important too.

 class Account
    {
        decimal balance;
        public Account() { Balance = 0.0m; }
        public Account(decimal amount)
        {
            Balance = amount;
        }
        public decimal Balance
        {
            get { return balance; }
            set
            {
                if (value >= 0)
                    balance = value;
                else
                {
                    balance = 0.0m;
                    Console.WriteLine("Wrong amount!Please check it.");
                }
            }
        }
        public virtual void Credit(decimal amount)
        {
            Balance += amount;
        }
        public virtual bool Debit(decimal amount)
        {
            if (Balance >= amount)
            {
                Balance -= amount;
                return true;
            }
            else
            {
                Console.WriteLine("Sorry! Debit amount exceeded acount balance!");
                return false;
            }
        }
    }
This question has already been answered. Start a new discussion instead.