Using C# and Windows Forms (WinForms), design and implement a
standalone desktop
application that fulfils the following requirements:
1. The user shall be able to enter the following values:
a. Gross monthly income (before deductions).
b. Estimated monthly tax deducted.
c. Estimated monthly expenditures in each of the following
categories:
i. Groceries
ii. Water and lights
iii. Travel costs (including petrol)
iv. Cell phoneand& telephone
v. Other expenses
2. The user shall be able to choose between renting accommodation
or buying a property.
3. If the user selects to rent, the user shall be able to enter the
monthly rental amount.
4. If the user selects to buy a property, the user shall be
required to enter the following
values for a home loan:
a. Purchase price of property.
b. Total deposit.
c. Interest rate (percentage).
d. Number of months to repay (between 240 and 360).
5. The software shall calculate the monthly home loan repayment for
buying a property
based on the values that the user entered. (See
https://www.siyavula.com/read/maths/grade-10/finance-and-growth/09-finance-andgrowth-
03 for more information on how to calculate this).
6. If the monthly home loan repayment is more than a third of the
user’s gross monthly
income, the software shall alert the user that approval of the home
loan is unlikely.
7. The user shall be able to choose whether to buy a vehicle.
8. If the user selects to buy a vehicle, the user shall be required
to enter the following values
for vehicle financing:
a. Model and make.
b. Purchase price.
c. Total deposit.
d. Interest rate (percentage).
e. Estimated insurance premium.
9. The software shall calculate the total monthly cost of buying
the car (insurance plus loan
repayment). Assume that all cars will be repaid over a period of
five years.
10. The software shall calculate the available monthly money after
all the specified deductions
have been made.
11. The software shall not persist the user data between runs. The
data shall only be stored in
memory while the software is running.
Non-functional requirements:
1. You are required to use internationally acceptable coding
standards (as practised in
previous modules e.g. PROG6211). Include comprehensive comments
explaining variable
names, methods and the logic of programming code.
2. You are required to use a generic collection to store all the
expenses. To facilitate this, you
can create an abstract class Expense, from which HomeLoan, etc. can
be derived.
3. You are required to create a custom class library that contains
the classes related to the
logic of calculating the various values. The application project
should make use of the
custom class library.
18; 19; 20 2020
© The Independent Institute of Education (Pty) Ltd 2020
Page 6 of 18
Submit the following items for this task:
1. Source code including both the class library and WinForms
application.
2. Unified Modelling Language (UML) class diagram showing the
classes in both the class
library and WinForms application. You may use any software of your
choosing to create the
diagram, but the file that you submit must be a .PDF export of your
diagram.
3. A readme file with instructions for how to compile and run the
software.
The following code shows how the program performs its calculations.
// Calculate the interest compounded monthly. private void btnGo_Click(object sender, EventArgs e) { // Get the parameters. decimal monthly_contribution = decimal.Parse( txtMonthlyContribution.Text, NumberStyles.Any); int num_months = int.Parse(txtNumMonths.Text); decimal interest_rate = decimal.Parse( txtInterestRate.Text.Replace("%", "")) / 100; interest_rate /= 12; // Calculate. lvwBalance.Items.Clear(); decimal balance = 0; decimal total_interest = 0; decimal total_principle = 0; for (int i = 1; i <= num_months; i++) { // Display the month. ListViewItem new_item = lvwBalance.Items.Add(i.ToString()); // Display the interest. decimal interest = balance * interest_rate; new_item.SubItems.Add(interest.ToString("c")); total_interest += interest; new_item.SubItems.Add(total_interest.ToString("c")); // Add the contribution. balance += monthly_contribution; total_principle += monthly_contribution; new_item.SubItems.Add(total_principle.ToString("c")); // Display the balance. balance += interest; new_item.SubItems.Add(balance.ToString("c")); } // Scroll to the last entry. lvwBalance.Items[lvwBalance.Items.Count - 1].EnsureVisible(); }
The code first gets the input parameters. It passes the parameter NumberStyles.Any to decimal.Parse so it can parse currency values. It also removes the percentage symbol from the interest rate, if it present.
The program then clears its ListView and then loops through the months being studied.
For each month, the code calculates and displays the interest on the current balance. It then adds the current interest to the total interest and displays that.
Next the program adds this month’s contribution to the total balance and the total principle, and displays those values. Finally it displays the new balance.
After it finishes the loop, the code calls the EnsureVisible method for the ListView control’s last entry to scroll to the end of the list.
This kind of investment has two benefits. First it makes you contribute a relatively small amount or principle each month so over time the principle adds up. Second the interest is added to the balance so over time older interest generates more interest. In this example during the final month the accumulated interest is about 30% of the total balance so roughly 30% if the interest is generated by the interest. If you continued this example for 18 years and 1 month, the total interest would exceed the total principle.
Get Answers For Free
Most questions answered within 1 hours.