Question: For this assignment, you will be writing a java program that calculates stock values including total share value on stocks owned, purchase price, and annual
For this assignment,\ you will be writing a java program that calculates stock values including total share value on stocks owned, purchase price, and annual dividend yield based on users inputs. The problem description has been broken down into two sets of requirements, with the first requiring only if statements and the second requiring looping structures. After getting input, if the user indicated that they have stock shares, you will calculate: - Overall stock purchase value based on the number of shares the user has and what they paid for them. - Current stock value based on the number of shares the user has and what the current market price is. - Any gain or lose based on the previous calculations. - Annual Dividend Yield - Annual Dividend payout based on number of shares owned. If the user indicates that they do not have stock shares, the program will ask them how many shares they would like to purchase. The program will then calculate: - Stock value based on number of share to purchase and current market price. - Annual Dividend Yield. - Annual Dividend payout based on number of share the user wants to purchase. In both cases, if the company does not payout an annual dividend, the output should indicate that annual dividends are not applicable. Verify that that all of your paths through your code are functioning properly, then add the functionality to your existing code for verifying valid input data. Stock Value This program is to be used by its users (investor) to evaluate company stock values - of stocks that are owned by the user - or, for the purchase of a stock that the user has an interest in. You will be calculating the following to help an investor evaluate their current stock investments or future stock investments: - Value of stock at the time of purchase - Value of stock at the current market price - Gain or loss if shares were sold - Annual Dividend Yield of either of the above Company stock dividend history information can be obtained from https://www.nasdaq.com/marketactivity/stocks . Input the stock symbol and click on the Dividend History link. Note the following: Many companies payout annual dividends and this information can be beneficiary to some investors when evaluating the purchase or sale of a stock. The investor can look at annual dividend yields, a financial ratio that indicates how much a company pays out in dividends each year relative to its share price. Dividend yield is a way to measure how much cash flow you are getting for each dollar invested in an equity position. In other words, it measures how much "bang for your buck" you are getting from dividends. In the absence of any capital gains, the dividend yield is effectively the return on investment for a stock. Investors who require a minimum stream of cash flow from their investment portfolio can secure this cash flow by investing in stocks paying relatively high, stable dividend yields. You will be prompting the user to enter the following information in the following order: - Enter name of the company that the user owns stock with, or stock they are interested in purchasing. - Enter stock ticker symbol - Enter annual dividend payout per share - Enter number of stock shares owned - Enter the purchase price of owned shares - If owned stock shares = 0, Enter number of shares to purchase - If owned stock shares = 0, Enter current market price for shares to purchase Given the users inputs, your program must determine and output: [1] Total stock value of owned shares using price at purchase [2] Total stock value of owned shares using current market price [3] Gain or loss [4] Annual dividend paid per share, N/A if no dividend is paid out [5] If annual dividend paid, output the annual dividend yield percentage (% symbol required). [6] If annual dividend paid, output total annual dividend based on number of shares owned or want to purchase. The above outputs must be formatted to 2 decimal places and include dollar sign or percentages, as required.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
