The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
language is c++
asked us to use do while loop.
my code got messed up when i try to use do loop. Can someone help me? this problem is worth of 50 points.
due today at 10.59 pm
Problem description
An investor has the opportunity to invest a minimum of $10,000 in an investment. We want to write a program to help him/her determine the future value of the investment. The program will ask the user to enter the investment amount, the annual interest rate, and the number of months of the investment to be used as inputs in calculating the future value of the investment. Your program must calculate compounded interest monthly.
This is done in the loop in the pseudo code below. Make sure you read and understand the pseudo code before you start writing your application.
Write the source code for a program that implements the pseudo code algorithm given below. Pseudo code:
Function main:
Do
Call a function to get a minimum “initial investment amount” of $10,000 from the user If (the “initial investment amount is != 0) Call a function to get the “annual interest rate”. It must be non-negative Call a function to get the “number of months” of the investment. It must be nonnegative Calculate the “monthly interest rate” by dividing the “annual interest rate” by 12 and then dividing the resulting value by 100 (make sure you don’t get truncation of results here) Call a function to calculate and return the future value of you investment. You will have to pass the “initial investment amount”, the “number of months”, and the “monthly interest rate” to the function. Call a function to display a message indicating the future value of the investment along with the initial investment and the number of months. End if End of Do while (initial investment amount is != 0) Function to calculate the future value: Save the “initial investment amount” into ”investment balance” Repeat for the “number of months” of the investment (note that 1. and 2. are part of the loop)
1. Calculate the “interest earned” by multiplying the “investment balance” by the “monthly interest rate”
2. Increase the value of ”investment balance” by the “interest earned” Function to get the “initial investment amount” Do the following until you get an investment amount that is $10,000 or more (the numbered items are in a loop):
1. Display a message to telling the application user to enter the initial investment amount
2. Read in the investment amount
3. If the investment amount is 0 exit out of the loop
4. If the investment amount is less than $10,000
Then Display a message to indicate that the initial investment amount is incorrect
Else
Exit out of the loop
Return the initial investment amount to the calling function
The functions to read in the “annual interest rate and the “number of months” will need input validation code similar to the “initial investment amount” function.
The display function will display the number of months, the initial investment and the future value of the investment. These values need to be passed to the function.
The following is sample output from the program.
Input is in bold: The minimum investment is $10000.00.
Enter the amount of the investment: 5000 [Enter]
Error, the minimum investment is $10000.00.
Enter the amount of the investment: 9999 [Enter] Error, the minimum investment is $10000.00.
Enter the amount of the investment: 10000 [Enter] Enter the annual interest rate: -3 [Enter] Error, the interest rate should not be negative.
Enter the annual interest rate: 3 [Enter] Enter the number of months of the investment: -12 [Enter] Error, the number of months should not be negative. Enter the number of months of the investment: -1 [Enter] Error, the number of months should not be negative. Enter the number of months of the investment: 12 [Enter] After 12 months your investment of $10000.00 will be worth $10304.16.
The minimum investment is $10000.00.
Enter the amount of the investment: 50000 [Enter] Enter the annual interest rate: 2.5 [Enter] Enter the number of months of the investment: 6 [Enter] After 6 months your investment of $50000.00 will be worth $50628.26. The minimum investment is $10000.00. Enter the amount of the investment: 0 [Enter] Run your program with the data from the sample above. Note that we test to make sure the interest rate is not less than zero and that the minimum investment is at least 10,000. Also run your program with $50,000.00 as the investment, an annual interest rate of 2.5%, for 6 months.