Click here to Skip to main content
15,916,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
​
namespace Lab4
{
    class Program
    {
        static void Main(string[] args)
​
        {
            SavingAccount aSavingAccount;
            List<savingaccount> accounts = new List<savingaccount>();
            while (true)
            {
                Console.Write("Please enter the account owner's name: ");
                string Owner = Console.ReadLine();
​
                if (Owner == "")
                    break;
​
                Console.Write("Please enter the initial deposit amount for the saving account: ");
                string entry1 = Console.ReadLine();
                double InitialDepositAmount = double.Parse(entry1);
               
                Console.Write("Please enter the monthly deposit amount for the saving account: ");
                string entry2 = Console.ReadLine();
                double MonthlyDepositAmount = double.Parse(entry2);
​
                aSavingAccount = new SavingAccount(Owner, InitialDepositAmount);
                aSavingAccount.MonthlyDepositAmount = MonthlyDepositAmount;
​
                accounts.Add(aSavingAccount);
​
            } 
​
            foreach (SavingAccount account in accounts)
            {
                for(int i = 0; i < 6; i++)
                {
                    account.Withdraw(SavingAccount.MonthlyFee);
                    account.Deposit(account.MonthlyDepositAmount);
                    account.Deposit(SavingAccount.MonthlyInterestRate * account.Balance);
                }
                Console.WriteLine("After 6 months, {0}'s account (#{1}), has a balance of: {2:C}", account.Owner, account.AccountNumber, account.Balance);
            }
            
        }
    }


What I have tried:

I tried to run in another window of visual studio but its showing all red line errors for full line code
Posted
Updated 2-Mar-18 5:14am
v4
Comments
CHill60 2-Mar-18 11:00am    
What do you mean by "is not working". If your code is showing all red lines then you have compile errors - find them and fix them

1 solution

To start with, C# is case sensitive, so
SavingAccount aSavingAccount;
Is not the same class as
List<savingaccount> accounts = new List<savingaccount>();
And since they are different classes, the latter can';t contain instances of the former! Plus, one is probably wrong so the compiler is probably telling you "I can't find class XXX".

The "Red Lines" are telling "there is a problem with this code" - if you look at the Errors pane it will give you a text description of what the problem is. (Double click the error message, and it'll take you direct to the line in error.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900