Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The problem descriptions will usually show at least one test case and the resulting correct output. However, you should test your program on other test
The problem descriptions will usually show at least one test case and the resulting correct output. However, you should test your program on other test cases (that you make up) as well. Making up good test cases is a valuable programming skill, and is part of ensuring your code solution is correct. Problem A: Investments to the moon (20 points) Pretend you have some money that you want to invest in the stock market. Ask the user for: 1. The initial investment 2. Yearly estimated market growth 3. How much (if any) you wish to withdraw from the account per year Example 1 (user input is underlined for clarity, underlined text in your program is not needed). Further note that PDFs will sometimes use 2 spaces where our code only s 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 1000 Yearly grouth rate? 0.1 Yearly withdraw amount? 50 Desired belance? 1000000 Yeara: 80 Balance at end: 1.0247e+06 Amount withdrawn over period: 4000 4. The desired level of money you wish to t Example 2 (user input is underlined for clarity, underlined text in your program is not needed). Further note that PDFs will sometimes use 2 spaces where our code only uses 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 1000 Yearly growth rate? 0.1 Yearly withdraw mount? O Desirad balance? 1000000 The growth formula per year is simply: Meyer = Moncadky (1 + rate) Assume you withdraw money from the account after it grows (so apply the growth rate before withdrawing). You cannot withdraw more than the account hus! Find out how long it takes to reach the desired amount of money (if it is reachable at all). If the account hits zero money, stop and tell them all the data Hints and Notes: . It's worth double-checking your understanding of the math here. Get a calculator out and try one of the examples out yourself to make sure it all makes sense . Remember to include the crath> library for mathematical operations. . . Make sure to match the provides format EXACTLY. Failure to do this will result in a grade of 0. Unlike lest homework, we want the user input to be entered on the same line as the prompts (Notice in the examples below how the numers are on the same line as the prompt this time!) - Notice that the expected output format has an empty line BEFORE the "years" output. While there is no cout in the loop in our example you may find it useful to put cout state- ments in the loop while testing so you can visualize what is bappening in the loop. Years: 73 Balance at end: 1.051158+06 Amount withdrawn over period: 0 Example 3 (laser input is underlined for clarity, underlinex text in your program is not needex). Further note that PDFs will sometimes use 2 spaces where our cucle only uss 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 100 Yearly grouth rate? 0.1 Yearly withdraw amount? 99999999 Desired balance? 1000000 Examples and format demonstration Follow the format shown in the examples exactly. Otherwise the grading program will not be able to understand your final answer. Years: 1 Balance at end: 0 Anount withdrawn over period: 110 The problem descriptions will usually show at least one test case and the resulting correct output. However, you should test your program on other test cases (that you make up) as well. Making up good test cases is a valuable programming skill, and is part of ensuring your code solution is correct. Problem A: Investments to the moon (20 points) Pretend you have some money that you want to invest in the stock market. Ask the user for: 1. The initial investment 2. Yearly estimated market growth 3. How much (if any) you wish to withdraw from the account per year Example 1 (user input is underlined for clarity, underlined text in your program is not needed). Further note that PDFs will sometimes use 2 spaces where our code only s 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 1000 Yearly grouth rate? 0.1 Yearly withdraw amount? 50 Desired belance? 1000000 Yeara: 80 Balance at end: 1.0247e+06 Amount withdrawn over period: 4000 4. The desired level of money you wish to t Example 2 (user input is underlined for clarity, underlined text in your program is not needed). Further note that PDFs will sometimes use 2 spaces where our code only uses 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 1000 Yearly growth rate? 0.1 Yearly withdraw mount? O Desirad balance? 1000000 The growth formula per year is simply: Meyer = Moncadky (1 + rate) Assume you withdraw money from the account after it grows (so apply the growth rate before withdrawing). You cannot withdraw more than the account hus! Find out how long it takes to reach the desired amount of money (if it is reachable at all). If the account hits zero money, stop and tell them all the data Hints and Notes: . It's worth double-checking your understanding of the math here. Get a calculator out and try one of the examples out yourself to make sure it all makes sense . Remember to include the crath> library for mathematical operations. . . Make sure to match the provides format EXACTLY. Failure to do this will result in a grade of 0. Unlike lest homework, we want the user input to be entered on the same line as the prompts (Notice in the examples below how the numers are on the same line as the prompt this time!) - Notice that the expected output format has an empty line BEFORE the "years" output. While there is no cout in the loop in our example you may find it useful to put cout state- ments in the loop while testing so you can visualize what is bappening in the loop. Years: 73 Balance at end: 1.051158+06 Amount withdrawn over period: 0 Example 3 (laser input is underlined for clarity, underlinex text in your program is not needex). Further note that PDFs will sometimes use 2 spaces where our cucle only uss 1. (In general I do not recommend copy/pasting from PDFS) Initial investment? 100 Yearly grouth rate? 0.1 Yearly withdraw amount? 99999999 Desired balance? 1000000 Examples and format demonstration Follow the format shown in the examples exactly. Otherwise the grading program will not be able to understand your final answer. Years: 1 Balance at end: 0 Anount withdrawn over period: 110
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started