Help with try/catch and try/parse? This is the program I have to make inside of
ID: 3664489 • Letter: H
Question
Help with try/catch and try/parse?
This is the program I have to make inside of Microsoft Visual Studios (using C#):
(a calculator link if you can't see it: http://i.imgur.com/zoUgakZ.png)
I made all of the physical buttons in the GUI form, I just need to write the programming parts as followed (I understand to click on the buttons for the click events, I just need to write the code blocks). You can name the variables/buttons whatever you want because I will change them, I just need the coding part.
Thank you.
Instructions:
Except for the Clear button, all of your code goes into the Calculate button's click event handler.
Use try/catch exception handling. So, all of your code, including variable declarations will go inside a single try block.
In addition, you must validate the two numbers. Do 2 forms of validation:
First, use TryParse to insure that the number is valid. Don't overthink this. Use double.TryParse in its simplest form within an If statement for each number.
If TryParse returns false, display the appropriate error message, put focus on the textbox, and use the return method to exit the function. The syntax is simply: return;
Second, if chkMaxNumber is selected AND the first number is greater than 100, display the error message, put focus on the textbox and exit the function using return. In your if statement condition, use a logical AND operator to test the condition. Do not use a nested If.
Do this for each of the two numbers.
Explanation / Answer
We know the stock has a required return of 11% and the dividend and capital gains yield are equal, so:
Dividend yield = 1/2(.11)
Dividend yield = .055 = Capital gains yield
Now we know both the dividend yield and capital gains yield. The dividend is simply the stock price times the dividend yield, so:
D1 = .055 x ($65.40) = 3.597
This is the dividend next year. The question asks for the dividend this year. Using the relationship between the dividend this year and the dividend next year:
D1 = D0(1 + g)
$3.597 = D0(1 + .055)
D0 = $3.597 / 1.055
D0 = $3.409 or $3.51
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.