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...
Problem 1 (50 pts). This problem will involve the nycflights13 dataset (including tables airlines, airports, planes...
Problem 1 (50 pts). This problem will involve the nycflights13 dataset (including tables airlines, airports, planes and weather), which we saw in class. It is available in both R and Python, however R is recommended for at least the visualization portion of the question. Start by installing and importing the dataset to your chosen platform. We will first use joins to search and manipulate the dataset, then we will produce a flightpath visualization. Question e) Produce a map that colors...
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?
In this problem, we will use our knowledge of maps and lists to build a spell-checking...
In this problem, we will use our knowledge of maps and lists to build a spell-checking program. The class Main contains the starter code for this problem; your task is to complete this program. You are provided with a file titled words.txt, which contains a list of valid English words, one per line. Your program should take as input a line of space-separated words representing a sentence. (No punctuation or capitalization will be used; all characters will be either the...
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 1 [50 pts] Consider a hard disk drive that has 5 double-sided platters, each surface...
Problem 1 [50 pts] Consider a hard disk drive that has 5 double-sided platters, each surface has 1000 tracks, each track has 256 sectors of size 512 bytes. Each block (disk page) comprises of 8 sectors. The seek time between adjacent tracks in 1ms and the average seek time between two random tracks is 25ms. The disk rotates at a speed of 7200 rpm (revolutions per minute). Let’s say, we have a file of size 1 MB and it contains...
# 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT