Explore BrainMass
Share

C# program with accounts

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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

© BrainMass Inc. brainmass.com October 25, 2018, 1:39 am ad1c9bdddf
https://brainmass.com/computer-science/c-sharp/c-program-with-accounts-270512

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
See Also This Related BrainMass Solution

Program Source Code for C#

There are 2 parts to this request.

I need a program source code in C# for this algorithm and a high level view of the solution. Original info is at the end.

Algorithm:

begin
Initlalize Leaded gas to 4.00

Initlalize Unleaded gas to 4.50

Initlalize Federal gas tax to 0.10

Initlalize Gas-n-Go service charge to 1.00

Initlalize Full-Service charge 2.00

Initlalize State sales tax 0.05
Read the input choice
Case of choice
1 Call LeadedGas()
2 Call UnleadedGas();
End case
end
//LeadedGas method
begin
Declare total
Calculate total= Leaded gas + Federal gas tax + Gas-n-Go service charge + Full-Service charge + State sales tax;
Return total
End

//method UnleadedGas
begin
Declare total
Calculate total= Unleaded gas + Federal gas tax + Gas-n-Go service charge + Full-Service charge + State sales tax;
Return total
end

Original problem:

develop a program that will calculate a customer's charges and total bill at the gasoline pump, taking into account the following:

o The per-gallon price for gas is determined by whether the customer purchases leaded or unleaded gasoline.

o A federal gasoline tax is applied to each gallon of gas, varying by whether the gas is leaded or unleaded.

o If the customers pump the gas themselves, there are no additional charges apart from state sales tax. If the customers do not pump the gas themselves, one of the following two service charges apply:

· Gas-n-Go charge: If the customer asks for Gas-n-Go (the station pumps the gas for the customer but performs no other service), a fixed service charge is applied to the bill. The charge does not vary by the amount of gas purchased; the price remains the same whether the customer purchases a half gallon of gas or 10 gallons.

· Full-Service charge: If the customer asks for Full-Service (the station pumps the gas, checks the oil, checks the air pressure in the tires, and cleans the car windows), a fixed charge is applied to the bill. The charge does not vary by the amount of gas purchased; the price remains the same whether the customer purchases a half gallon of gas or 10 gallons.

o A state sales tax is applied to the sum of all charges except for the federal gasoline tax.

View Full Posting Details