Question

In: Computer Science

(50 pts) Enhance the Future Goal Problem. a. Use lists to track and store the inputs...

(50 pts) Enhance the Future Goal Problem. a. Use lists to track and store the inputs and outputs for each Future Value investment the user calculates. b. Modify the existing code so that it correctly calculates the numbers months/years it takes to achieve a monetary goal. c. Write code that properly stores each input/output value in its corresponding list. d. Comment on the provided code for the History button. You do NOT need to modify the included code! It will work correctly if the rest of your program is properly coded. e. Validation is not necessary for this problem. When you are finished: zip the original folder (ISTM250Exam2) and name the zipfile based upon your name (e.g. BooneTedExam2).

Solutions

Expert Solution

Short Summary:

  • You have to declare class level generic lists to keep track of the input/out values
  • Add the input/output values to the corresponding list, when clicking Calculate button
  • Display the formatted string by looping through the lists when clicking History button

**************Please upvote the answer and appreciate our time.************

Source Code:

FRMFutureGoal.cs File:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Windows.Forms;

namespace FutureValue

{

    public partial class FRMFutureGoal : Form

    {

        // Use lists to store input/output values

        List<decimal> historyInvestments = new List<decimal>();

        List<decimal> historyInterestRates = new List<decimal>();

        List<decimal> historyGoals = new List<decimal>();

        List<int> historyMonths = new List<int>();

        List<decimal> historyYears = new List<decimal>();

        public FRMFutureGoal()

        {

            InitializeComponent();

        }

        private void btnCalculate_Click(object sender, EventArgs e)

        {

            // Read the values from text boxes

            decimal monthlyInvestment = Convert.ToDecimal(txtMonthlyInvestment.Text);

            decimal yearlyInterestRate = Convert.ToDecimal(txtInterestRate.Text);

            decimal futureGoalValue = Convert.ToDecimal(txtFutureValue.Text);

  

            decimal monthlyInterestRate = yearlyInterestRate / 12 / 100;

            // Assume current future value is ZERO

            decimal futureValue = 0m;

            int months = 0;

            // Add the monthly investment to the current future value, until it equals or exceeds Goal Value

            while(futureValue < futureGoalValue)

            {

                futureValue = (futureValue + monthlyInvestment)

                            * (1 + monthlyInterestRate);

                // Increment month for every iteration

                months++;

            }

            txtMonths.Text = months.ToString();

            // Convert months into year

            decimal years = (decimal)months / (decimal)12;

            txtYears.Text = years.ToString("0.00");

            txtMonthlyInvestment.Focus();

            // Add the input/output values to corresponding lists

            historyInvestments.Add(monthlyInvestment);

            historyInterestRates.Add(yearlyInterestRate);

            historyGoals.Add(futureGoalValue);

            historyMonths.Add(months);                                                                   

            historyYears.Add(years);

        }

        private void btnExit_Click(object sender, EventArgs e)

        {

            this.Close();

        }

        private void btnHistory_Click(object sender, EventArgs e)

        {

            // heading

            string history = string.Format("{0,-15}{1, -15}{2, -20}{3, -15}{4, -15}\n", "inv", "IR", "Goal", "mths", "yrs");

            // Loop through the lists and add rows

            for(int index = 0; index < historyInvestments.Count; index++)

            {

                history += string.Format("{0,-10}{1, -10}{2, -20}{3, -10}{4, -10}\n", historyInvestments[index].ToString("c"),

                    (historyInterestRates[index].ToString("0.00") + "%"), historyGoals[index].ToString("c"), historyMonths[index], historyYears[index].ToString("0.00"));

            }

            // Display in a meesagebox

            MessageBox.Show(history);

        }

    }

}

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

FRMFutureGoal.designer.cs File

namespace FutureValue

{

    partial class FRMFutureGoal

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }

        #region Windows Form Designer generated code

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            this.label1 = new System.Windows.Forms.Label();

            this.txtMonthlyInvestment = new System.Windows.Forms.TextBox();

            this.txtInterestRate = new System.Windows.Forms.TextBox();

            this.label2 = new System.Windows.Forms.Label();

            this.txtFutureValue = new System.Windows.Forms.TextBox();

            this.label3 = new System.Windows.Forms.Label();

            this.txtMonths = new System.Windows.Forms.TextBox();

            this.label4 = new System.Windows.Forms.Label();

            this.txtYears = new System.Windows.Forms.TextBox();

            this.label5 = new System.Windows.Forms.Label();

            this.btnCalculate = new System.Windows.Forms.Button();

            this.btnExit = new System.Windows.Forms.Button();

            this.btnHistory = new System.Windows.Forms.Button();

            this.SuspendLayout();

          //

            // label1

            //

            this.label1.AutoSize = true;

            this.label1.Location = new System.Drawing.Point(84, 57);

            this.label1.Name = "label1";

            this.label1.Size = new System.Drawing.Size(146, 20);

            this.label1.TabIndex = 0;

            this.label1.Text = "Monthly Invesment:";

            //

            // txtMonthlyInvestment

            //

            this.txtMonthlyInvestment.Location = new System.Drawing.Point(256, 54);

            this.txtMonthlyInvestment.Name = "txtMonthlyInvestment";

            this.txtMonthlyInvestment.Size = new System.Drawing.Size(185, 26);

            this.txtMonthlyInvestment.TabIndex = 1;

            //

            // txtInterestRate

            //

            this.txtInterestRate.Location = new System.Drawing.Point(256, 118);

            this.txtInterestRate.Name = "txtInterestRate";

            this.txtInterestRate.Size = new System.Drawing.Size(185, 26);

            this.txtInterestRate.TabIndex = 3;

            //

            // label2

            //

            this.label2.AutoSize = true;

            this.label2.Location = new System.Drawing.Point(84, 121);

            this.label2.Name = "label2";

            this.label2.Size = new System.Drawing.Size(155, 20);

            this.label2.TabIndex = 2;

            this.label2.Text = "Yearly Interest Rate:";

            //

            // txtFutureValue

            //

            this.txtFutureValue.Location = new System.Drawing.Point(256, 181);

            this.txtFutureValue.Name = "txtFutureValue";

            this.txtFutureValue.Size = new System.Drawing.Size(185, 26);

            this.txtFutureValue.TabIndex = 5;

            //

            // label3

            //

            this.label3.AutoSize = true;

            this.label3.Location = new System.Drawing.Point(84, 184);

            this.label3.Name = "label3";

            this.label3.Size = new System.Drawing.Size(158, 20);

            this.label3.TabIndex = 4;

            this.label3.Text = "Future Goal Amount:";

            //

            // txtMonths

            //

            this.txtMonths.Location = new System.Drawing.Point(256, 251);

            this.txtMonths.Name = "txtMonths";

            this.txtMonths.ReadOnly = true;

            this.txtMonths.Size = new System.Drawing.Size(185, 26);

            this.txtMonths.TabIndex = 7;

            //

            // label4

            //

            this.label4.AutoSize = true;

            this.label4.Location = new System.Drawing.Point(84, 254);

            this.label4.Name = "label4";

            this.label4.Size = new System.Drawing.Size(144, 20);

            this.label4.TabIndex = 6;

            this.label4.Text = "Number of Months:";

            //

            // txtYears

            //

            this.txtYears.Location = new System.Drawing.Point(256, 320);

            this.txtYears.Name = "txtYears";

            this.txtYears.ReadOnly = true;

            this.txtYears.Size = new System.Drawing.Size(185, 26);

            this.txtYears.TabIndex = 9;

            //

            // label5

            //

            this.label5.AutoSize = true;

            this.label5.Location = new System.Drawing.Point(84, 323);

            this.label5.Name = "label5";

            this.label5.Size = new System.Drawing.Size(133, 20);

            this.label5.TabIndex = 8;

            this.label5.Text = "Number of Years:";

            //

            // btnCalculate

            //

            this.btnCalculate.Location = new System.Drawing.Point(137, 373);

            this.btnCalculate.Name = "btnCalculate";

            this.btnCalculate.Size = new System.Drawing.Size(122, 44);

            this.btnCalculate.TabIndex = 10;

            this.btnCalculate.Text = "Calculate";

            this.btnCalculate.UseVisualStyleBackColor = true;

            this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);

            //

            // btnExit

            //

            this.btnExit.Location = new System.Drawing.Point(295, 373);

            this.btnExit.Name = "btnExit";

            this.btnExit.Size = new System.Drawing.Size(122, 44);

            this.btnExit.TabIndex = 11;

            this.btnExit.Text = "Exit";

            this.btnExit.UseVisualStyleBackColor = true;

            this.btnExit.Click += new System.EventHandler(this.btnExit_Click);

            //

            // btnHistory

            //

            this.btnHistory.Location = new System.Drawing.Point(201, 451);

            this.btnHistory.Name = "btnHistory";

            this.btnHistory.Size = new System.Drawing.Size(109, 39);

            this.btnHistory.TabIndex = 12;

            this.btnHistory.Text = "History";

            this.btnHistory.UseVisualStyleBackColor = true;

            this.btnHistory.Click += new System.EventHandler(this.btnHistory_Click);

            //

            // FRMFutureGoal

            //

            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(502, 539);

            this.Controls.Add(this.btnHistory);

            this.Controls.Add(this.btnExit);

            this.Controls.Add(this.btnCalculate);

            this.Controls.Add(this.txtYears);

            this.Controls.Add(this.label5);

            this.Controls.Add(this.txtMonths);

            this.Controls.Add(this.label4);

            this.Controls.Add(this.txtFutureValue);

            this.Controls.Add(this.label3);

            this.Controls.Add(this.txtInterestRate);

            this.Controls.Add(this.label2);

            this.Controls.Add(this.txtMonthlyInvestment);

            this.Controls.Add(this.label1);

            this.MaximizeBox = false;

            this.MinimizeBox = false;

            this.Name = "FRMFutureGoal";

            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            this.Text = "Future Value Goal";

            this.ResumeLayout(false);

            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;

        private System.Windows.Forms.TextBox txtMonthlyInvestment;

        private System.Windows.Forms.TextBox txtInterestRate;

        private System.Windows.Forms.Label label2;

        private System.Windows.Forms.TextBox txtFutureValue;

        private System.Windows.Forms.Label label3;

        private System.Windows.Forms.TextBox txtMonths;

        private System.Windows.Forms.Label label4;

        private System.Windows.Forms.TextBox txtYears;

        private System.Windows.Forms.Label label5;

        private System.Windows.Forms.Button btnCalculate;

        private System.Windows.Forms.Button btnExit;

        private System.Windows.Forms.Button btnHistory;

    }

}

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

Sample Run:

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

Feel free to rate the answer and comment your questions, if you have any.

Please upvote the answer and appreciate our time.

Happy Studying!!!

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


Related Solutions

The goal of this assignment is to implement a set container using linked lists. Use the...
The goal of this assignment is to implement a set container using linked lists. Use the authors bag3.h and bag3.cpp as a basis for implementing your set container using linked lists. The authors bag3.h and bag3.cpp can be found here https://www.cs.colorado.edu/~main/chapter5/ Since you are using the authors bag3.h and bag3.cpp for your Set container implementation, make sure that you change the name of the class and constructors to reflect the set class. Additionally you will need to implement the follow...
Your goal is to save up $30,000 to use as a future down payment.If you...
Your goal is to save up $30,000 to use as a future down payment. If you save $3,236 every year in an account that earns 11% annually, how long will you be saving?
Can anyone use python to solve this problem: Part B: List of lists The aim of...
Can anyone use python to solve this problem: Part B: List of lists The aim of Part B is to learn to work with list of lists. You may want to open the file lab05b_prelim.py in the editor so that you can follow the task description. The first part of the file lab05b_prelim.py defines a variable called datasets. The variable datasets is a list of 4 lists. This part consists of 2 tasks. Task 1: We ask you to type...
1. [50 pts] Suppose we have the following production function generated from the use of only...
1. [50 pts] Suppose we have the following production function generated from the use of only one variable input, labour (L): ??? = 0.4? + 0.09?2 − 0.0035?3 Where TPP represents the total physical product and L is measured in 1000 hour increments (ie 1.5=1500 hours). The Marginal Physical Product curve is represented by: ??? = 0.4 + 0.18? − 0.0105?2 a) [5 pts] What is the equation that shows the relationship between the amount of labour used and labours...
This problem requires you to use a heap to store items, but instead of using a...
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap, you need to assign a priority (key) to each item that will determine where it is inserted in the heap a) Show how to assign priorities to items to implement a first-in, first-out queue with a heap. b) Show how to assign priorities to items to implement a first-in, last-out...
# Problem 5: Use R to compute: # (a)(6 pts) Set three random vectors of 1000...
# Problem 5: Use R to compute: # (a)(6 pts) Set three random vectors of 1000 random numbers as follows: # x1: from Unif(0,5), # x2: from Binom(70,0.2), and # x3: from Exp(1). # Define y = x1 + 4*x2 + 8*x3 + 10 + Err, where Err ~ N(0,sd=10). # (b)(6 pts) Create a dataframe df containing these four variables # and create scatterplots of all pairs of these four variables. # (c) Create a multiple regression model for...
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an...
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an indirect proof technique. (a) (10 pts) Prove indirectly that, if a 2 is a multiple of 31, then so is a. Your proof should not consist of 30 cases – this includes absolutely no implied cases using horizontal dots (· · ·) and/or vertical dots (. . .). (b) (15 pts) Using the result of question (a), prove that √ 31 is not a...
The purpose of this problem is to use graphic user interface (GUI) to interactively store grades...
The purpose of this problem is to use graphic user interface (GUI) to interactively store grades in a text file, rather than adding them manually to a script. Follow these steps to complete the program: Step 1. Use a question dialog box and ask the user “Do you want to run this Program?” with two options for “yes” and “no”. If the user’s answer is “yes”, go to the next step, otherwise, go to Step 6. Step 2. Create a...
Problem set 2: use the following table to answer questions 4-7 (40 pts total): # of...
Problem set 2: use the following table to answer questions 4-7 (40 pts total): # of children Frequencies 0 472 1 218 2 175 3 320 4 187 5 128 6 47 7 33 8 20 N 1,600 Please find the mean for numbers of children in this distribution (20 pts). # of children Frequencies How many # of children in each category: # of Children * Freq. in each column 0 472 0*472=0 1 218 2 175 3 320...
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap, you need to assign a priority (key) to each item that will determine where it is inserted in the heap 7a) Show how to assign priorities to items to implement a first-in, first-out queue with a heap. 7b) Show how to assign priorities to items to implement a first-in, last-out stack with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT