using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
public class AccountInfo
{
public int Number { get; set; }
public double Balance { get; set; }
public string LastName { get; set; } }
// private class members, creating new arrays
private int []
AcctNumber = new int[5];
private double []
AcctBalance = new double[5];
}
public static void Main()
{
List<AccountInfo> accounts = new List<AccountInfo>();
for (int index = 1; index < 6; index++)
{
AccountInfo acc = new AccountInfo();
Console.Write("Enter account number: " + index.ToString() + ": ");
acc.Number = int.Parse(Console.ReadLine());
Console.Write("Enter the account balance: ");
acc.Balance = double.Parse(Console.ReadLine());
}
}
class Accounts
{
public void fillAccounts()//fill arrays with user input
{
int x = 0;
for
(int i = 0; i < AcctNumber.Length; i++)
{
Console.Write("Enter account number: ");
AcctNumber[x] = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter account balance: ");
AcctBalance[x] = Convert.ToDouble(Console.ReadLine());
x++;
}
}
public void searchAccounts() //search account method to be called later in main()
{
int accountNum = 0;
bool isValid = false;
int x = 0;
Console.Write("Please enter account number to search for: ");
accountNum = Convert.ToInt32(Console.ReadLine());
while (x < AcctNumber.Length && accountNum != AcctNumber[x])
++x;
if(x != AcctNumber.Length)
{
isValid = true;
}
if(isValid)
{
Console.WriteLine("AcctNumber: {0} Balance: {1:c}", AcctNumber[x], AcctBalance[x]);
}
else
{
Console.WriteLine("You entered an invalid account number");
}
}
} //end public class Accounts
Getting errors do not know how to fix this. Here is the assignment instructions: Bank currently has only 5 customers.. At this point, each customer has one account, which includes an account number and balance.
1. An Account class that contains private data members; account number and balance.
2. A public class method to get the data.
3. A public class method to search for the a balance by account number.
4. A public class method to output the list of accounts and balances, with appropriate column headers.
5. A main( ) function that instantiates an array of Account objects, and allows user to input an account number and than have the program search for and display the associated balance and then display a list of all 5 balances.
6. Internal Documentation