Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Exercise 6 - 1 Enhance the Future Value application In this exercise, you'll enhance the Future Value application that you created in chapter 5 so

Exercise 6-1 Enhance the Future Value application
In this exercise, you'll enhance the Future Value application that you created in chapter 5 so it works like the one in figure 6-12.
Use refactoring to create the CalculateFutureValue () method
Open the application that's in the C:C#|Chapter06??FutureValue| directory.
Use refactoring as shown in figure 6-5 to refactor the calculation in the event handler and create a new method named CalculateFutureValue().
Test the application to make sure the new method works correctly.
Add the CalculateFutureValue() method without using refactoring
4. Press Ctrl+Z twice to return the code to the way it was before you refactored it.
5. Add a method named CalculateFutureValue() that works like the one in figure 6-12. To do that, type the start of the new method including its opening brace, and its closing brace will be added automatically. Then, move the related code from the btnCalculate_Click() method to the block within the new method and modify it where necessary.
6. Modify the code in the btnCalculate_Click() method so it calls the CalculateFutureValue() method. As you enter the call to the method, note how the IntelliSense feature helps you enter the arguments.
7. Test the application to make sure this new method works correctly.
Add an event handler for the TextChanged events
8. In the Form Designer, select the first text box. Then, click the Events button in the Properties window to display the Events list for that text box. Review the events that are available.
9. Enter "ClearFutureValue" to the right of the TextChanged event and press Enter. When you do, the Code Editor will open and an event handler named ClearFutureValue will be created. Enter a statement that clears the Future Value text box as shown in figure 6-12.
10. Open the frmFutureValue.Designer.cs file for the form, expand the Windows Form Designer generated code region if necessary, and locate the statements that set the properties of the Monthly Investment text box. At the end of those statements, you'll find a statement that wires the TextChanged event of this control to the ClearFutureValue() event handler.
11. Return to the Form Designer and select the Yearly Interest Rate text box. Drop down the list for the TextChanged event of this control, and notice that the ClearFutureValue event handler is included in this list. Select this event handl to wire the event to it. Repeat this process for the Number of Years text box.
12. Run the application and perform a calculation. Then, change the value that's displayed in one of the text boxes. When you do that, the value that's display for the Future Value text box should be cleared.
13. When you're sure the enhancements are working correctly, close the application.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions