• +1-617-874-1011 (US)
• +44-117-230-1145 (UK)

# Company Earnings Simulator

##### Company Earnings Simulator

You wish to simulate the annual earnings of a particular medium sized company. Create a C# WPF (desktop) application that will allow a user to enter a range of years and a range of minimum and maximum sales earnings and then generates and displays random sales figures, estimated taxes, expenses and profit figures.

1. Create a program that inputs the Starting Year and Ending Year, the Minimum Quarterly Sales and Maximum Quarterly Sales and then outputs simulated Quarterly Sales figures along with Sales Totals, Estimated Taxes and Expenses. Details on these calculations are given below.
2. Layout controls on a WPF window with suitable names as shown below
(you may use either a textbox or a listbox to output your table of results):
3. Calculate Button: When clicked, the calculate button should:
1. Get the inputs from the user (see validation rules in part (4) below)
2. Loop over the required number of years and perform the operations in steps (i) to (vi) below:
1. Call the GetSales() function (see part (5) below) to generate random sales figures for each quarter ( Q1 sales, Q2 Sales etc.)
2. Add up the 4 quarterly sales figures to get a Sales Total.
• Call the GetTaxes() function (see part (6) below) to determine the estimated Taxes.
1. Calculate the Expenses using the formula: Expenses = Sales Total * Expense Rate / 100
2. Calculate the Net Profit using the formula: Net Profit = Sales Total – Taxes – Expenses
3. Display a row in the output table. Note that the Sales Total, Taxes and Expenses values must always be calculated, but should only be displayed in the output columns if the corresponding checkbox is checked (see part 7 below).
• Input Validation: If the user inputs invalid values (see rules below) display an error message warning the user to correct their input. You may output your error messages using either a messagebox or a label on the window:
1. All inputs are required (no blank inputs allowed)
2. All inputs must be numbers (no non-numeric text can be entered)
3. The End Year must be later than the Start Year AND the End Year must not be more than 25 years after the Start Year (i.e. we will run the simulation for no more than 25 years)
4. The Maximum Quarterly Sales must be larger than the Minimum Quarterly Sales. Although the simulation will work best for realistic sales amounts, there are no restrictions on the size of these quarterly sales figures. These values may be INTEGERS – that is, we will run the simulation only for whole number dollar values, even though the outputs will show 2 decimal places.
5. The Expense Rate must be a floating point value between 0 to 100 %
6. No results should be calculated or displayed if the user does not enter valid inputs.
• GetSales() Function: This function/method should:
1. Accept a Minimum and a Maximum INTEGER number (taken from the Minimum Quarterly Sales and Maximum Quarterly Sales user inputs)
2. Return a random INTEGER value between these numbers
3. Except for a globally defined random number object, this function must operate only on the arguments passed into it and not access any global variables or input controls.
• GetTaxes() Function: This function/method should:
1. Accept a Sales Total value (taken from your calculated values in (3.b.ii)
2. Calculate and return a floating point number for the Taxes using the following
formula: Tax = Sales Total * Tax Rate / 100
3. The Tax Rates are listed in the following table:

Sales Total for the Year Tax Rate (%)

Is 0.00 up to but not including 100 000.00 0.0%

Is 100 000.00 up to but not including 175 000.00 10.0%

Is 175 000.00 up to but not including 250 000.00 15.0%

Is 250 000.00 up to but not including 350 000.00 25.0%

Is 350 000.00 or more 35.0%

1. This function must operate only on the arguments passed into it and not access any global variables or input controls.
• Checkboxes and Displayed Columns: The columns displayed in your output depend on the checkbox checked states:
1. The Sales Total column should be output only if the Show Sales Total checkbox is checked.
2. The Taxes column should be output only if the Show Taxes checkbox is checked.
3. The Expenses column should be output only if the Show Expenses checkbox is checked.
• No result should be calculated or displayed if the user does not enter valid inputs.
• Other Requirements and notes:
1. You may format your output table with any horizontal alignment that you like, but the output table must be well formatted with good vertically aligned columns. Make your table tidy.
2. Although the randomly generated Quarterly Sales figures are integer dollars, all other calculated and displayed values must be floating point numbers.
3. Use comments to describe the details of each important block of code, each function definition and formula.
4. Although you may be as detailed as you like, your comments must be clear, but do not have to be long. Just a few lines of comments that clearly describe the meaning of each important feature in your code is all that is needed.
5. Collaboration and problem solving with other students is allowed, But your work must be your own. Use good variable names and clear comments to demonstrate that you understand your work.

General Marking Scheme

10% Form layout and design

10% Clear and meaningful variable names and input control names