Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a (simplified) C# class for a bank account object with the following 3 pr

ID: 3835339 • Letter: C

Question

Create a (simplified) C# class for a bank account object with the following 3 properties: account number (int type), customer name (string type) and account balance (double type). Define an array type as the bank account class to store the 10 bank accounts. Use a "for loop" to generate 10 bank accounts accordingly to the following specification: (a) Each account number is 7 digits with 5 digits random number (from 10000 to 99999) plus 2 check digits. The check digits are the sum of the five digits added together. (b) Use a L to initialize 10 customer assign a name to each account customer names of your choice and randomly name without duplication. (c) Randomly create and assign a balance amount to the account balance property ranging from $100.00 to $5, 999.99. (d) Print the 10 account information during your creation of them, one line per account. Use one of the selection sort, bubble sort, or insertion sort to sort the array of 10 bank account objects into descending order of account balance. You just need to modify one of it to suit the object data type. Print the 10 account information after they are sorted in descending order of account balance one line per account. Compute and print the average account balance amount for the 10 accounts. Submit the C# code and the result screen shots of unsorted account listing, sorted account listing, and the average balance.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;

namespace BankApplication
{
    class AccountDetails
    {
       public int accountNumber;
       public string customerName;
       public double accountBalance;
     
       public int getAccountNumber() {
       return accountNumber;
        }
       public void setAccountNumber(int accountNumber) {
           this.accountNumber = accountNumber;
       }
       public String getCustomerName() {
           return customerName;
       }
       public void setCustomerName(String customerName) {
           this.customerName = customerName;
       }
       public double getAccountBalance() {
           return accountBalance;
       }
       public void setAccountBalance(double accountBalance) {
           this.accountBalance = accountBalance;
       }
    }
  
    class BankAccount{

        private AccountDetails[] bankAccounts = new AccountDetails[10];
        Random randumNumber = new Random();
        public BankAccount(){
            List<int> randomAccountNumbers = getListOfRandomNumbers(10000,99999);
            List<string> names = new List<string>()
            {
                "Amar",
                "Akbar",
                "Anthony",
                "David",
                "Reina",
                "Saul",
                "Bernard",
                "Danny",
                "Dimas",
                "Yuri"
            };
            for(int i=0; i<10; i++){
                bankAccounts[i] = new AccountDetails();
                bankAccounts[i].setAccountNumber(generateAccountNumber(randomAccountNumbers));
                bankAccounts[i].setCustomerName(generateCustomerName(names));
                bankAccounts[i].setAccountBalance(generateAccountBalance());
                Console.WriteLine("Account1: Account Number: {0}, Customer Name: {1}, Account Balance: {2}",bankAccounts[i].getAccountNumber(), bankAccounts[i].getCustomerName(), bankAccounts[i].getAccountBalance());
              
            }
        }

        //to generate 7 digit account number with first two digits to be the sum of last 5 digits.
        private int generateAccountNumber(List<int> randomAccountNumbers){
            int lastFiveDigits = randomAccountNumbers.ElementAt(0);
            randomAccountNumbers.RemoveAt(0);
            int temp = lastFiveDigits;
            int firstTwoDigits=0, r;
            while(temp!=0){
                r = temp % 10;
                temp = temp / 10;
                firstTwoDigits = firstTwoDigits + r;
            }
            return (firstTwoDigits*100000+lastFiveDigits);
        }
      
        private List<int> getListOfRandomNumbers(int maximum, int minimum){
            List<int> listNumbers = new List<int>();
            int number;
            for (int i = 0; i < 10; i++)
            {
              do {
                 number = randumNumber.Next(maximum, minimum);
              } while (listNumbers.Contains(number));
              listNumbers.Add(number);
            }
            return listNumbers;
        }
        private string generateCustomerName(List<string> names){
            int randomPosition = randumNumber.Next(names.Count);
            string randomName = names[randomPosition];
            names.RemoveAt(randomPosition);
            return randomName;
        }
      
        private double generateAccountBalance(){
            return randumNumber.NextDouble() * (5999.99 - 100.00) + 100.00;
        }
      
         public static void Main(string[] s){
        BankAccount accountApplication = new BankAccount();
        }
    }
      
}

This is the solution for first two questions.