Share
Explore BrainMass

C# program with accounts

Because an array is an object it must be declared using the new operator: int[ ] myarray = new int[5]; or it could be declared and initialized statically using the format

int[ ] myarray = {1, 3, 5, 7, 9};

Because the C# array is an object member of the Array class it also comes with a number of built-in methods such as Reverse, Sort and Binary Search. You can use the Reverse method

ACTUAL ASSIGNMENT REQUEST IS AS FOLLOWS:

[Assignment3_yourlastname.cs] Create a program that includes the following requirements:

1. Create an accounts class

2. Private class members for:

an array of 5 account numbers

an array of 5 account balances (currency)

an array of 5 account names (last name)

3. Public class methods:

a method to fill all three parallel arrays by keyboard inputs

a method to search the account number array and display

when found, the account number entered at the keyboard along with the corresponding balance and last name

if nothing is found for the account number entered display "You entered an invalid account" on the console

a method to compute and display the average of all 5 balances as currency (you must use the array's Length property at least once in this method)

4. In Main:

Instantiate one new accounts object

call the class method that will fill the accounts array

a menu detailing entries to select search (a or A), average (b or B) or exit (x or X)

accept an entry from the keyboard and use a while-loop to allow the user to make selections until an x or an X is entered

when an x or an X is entered terminate the while loop

5. Internal Documentation.

POSSIBLE OUTPUT SHOULD LOOK SOMETHING ALONG THE LINES OF THE FOLLOWING EXAMPLE:

Enter the integer account number 1

Enter the account balance 1111

Enter the account holder last name Stutte

Enter the integer account number 2

Enter the account balance 2222

Enter the account holder last name Stanton

Enter the integer account number 3

Enter the account balance 3333

Enter the account holder last name Staton

Enter the integer account number 4

Enter the account balance 4444

Enter the account holder last name Stiles

Enter the integer account number 5

Enter the account balance 5555

Enter the account holder last name Stone

*****************************************

enter an a or A to search account numbers

enter a b or B to average the accounts

enter an x or X to exit program

*****************************************

Enter an option ---> B

The average dollar amount for the accounts is: $3,333.00

*****************************************

enter an a or A to search account numbers

enter a b or B to average the accounts

enter an x or X to exit program

*****************************************

Enter an option ---> 4

you entered an incorrect option

*****************************************

enter an a or A to search account numbers

enter a b or B to average the accounts

enter an x or X to exit program

*****************************************

Enter an option ---> A

Enter an account number to search for 4

Account # 4 has a balance of $4,444.00 for customer Stiles

*****************************************

enter an a or A to search account numbers

enter a b or B to average the accounts

enter an x or X to exit program

*****************************************

Enter an option ---> X

Press any key to continue

PLEASE COMPILE AND RUN TO ENSURE CODE IS CORRECT BEFORE SENDING

THANKS

Solution Preview

Please find attached a C# project source and compiled. Rename the project using your last name. All the code is in file "Program.cs". Procedure "fillAccounts" will first request ...

Solution Summary

A C# console program will first request an entry of 5 account details (number, balance, name). After the entry is completed the program will offer user 3 menu choices: search for an account; calculate account average or exit the program. Validation of entry data is performed making sure proper numerical data is entered. Program is well commented.

$2.19