This is what my code looks like:
When I ran it it gave back errors saying something is wrong with my "scan.nextInt();" and my "marginOfSafety"
And this is an example of what it's supposed to look like:
Company name: Apple
Stock price: 107.73
Future value: 597.20
Required return on investment in percent: 15
Margin of Safety Discount in percent: 25
/* The above values were entered at run time, the bottom are computed */
Stock Apple at Today's Price 107.73
with Future Value 597.2 and Required ROI of 15.0%
At a 25.0% discount the sticker price is 147.6187064959783
and the price
you should pay is 110.71402987198373
And I just don't know how to fix those errors mentioned above so any help is appreciated. Thank you
Oh and it might help knowing the instructions:
Investment analysts will often project the future price of a company’s stock by considering the rate at which that
company has increased the value of its assets over the past 5-to-10 years. Here are some examples of estimates that
we’ve seen recently for two companies that you might have heard of:
Company Current Price (September 3, 2016) Estimated Future Value (2026)
Apple 107.73 597.20
Hanesbrands 26.40 110.99
Please note that, even though these are genuine estimates, we are NOT explaining the assumptions involved in the
estimation method. These are for illustration only, not for investment decision-making.
INPUT 1: The price of the stock today is price.
INPUT 2: Let’s call the Estimated Future Value of a company the fv.
Once you have an estimated future value of a company, you can decide how much you should be willing to pay for
it today. This involves two additional inputs:
INPUT 3: The minimum percentage amount per year that you are willing to earn on your investment. (For
example, you can earn 3.1% per year if you buy a bond issued by Barclays Bank that matures in August,
2021). Many investors, like Warren Buffett, look for a 15% return per year. Let’s call this variable
annualROI (short for Annual Return on Investment).
Given the annualROI and the fv, your program can calculate a stickerPrice for the stock. This is
the price you would pay today in order to achieve exactly an annualROI (such as 15%) return on
investment if you sell the stock for fv in 5 years. Allow the user to enter annualROI as a percentage,
such as 15 for 15%.
INPUT 4: The percentage discount you require off the sticker price before you’re willing to buy the stock.
This is often called the Margin of Safety discount. Investors want the discount in case the stock doesn’t
actually reach the estimated future value price. For example, it is common to require a 25% discount. Let’s
call this variable MarginOfSafety and interpret the entered number as a percentage.
To calculate the 10-years-in-the-future value of a stock:
stickerPrice = ____fv________
(1 + annualROI)10
The power of 10 reflects the number of years.
To determine the price you should be willing to pay today:
buyPrice = ((100-marginOfSafety)/100) * stickerPrice
Write a program (name it Sticker) that:
1. Asks the user what company she is considering. Use scanner to accept the value and store it in a
string.
2. Ask the user for the four inputs described above. Use scanner to accept the values and store them in
appropriate variables.
3. Perform the calculations described above then then display the inputs, the sticker price and the buy price.
Label your outputs so we can understand what the numbers mean.