Question: The code I have is not outputting what the instructor asked. Need help writing the program for this assignment Lab #4 COSC 1436 Summer 2018
Lab #4 COSC 1436 Summer 2018 Your best friend is investing in stocks. He has a system where he purchases a stock three days before the stock pays dividends, and then sells that stock 3 days afterward. He wants you to write me compute how much he earns (or loses) when he does that. You method need to accept: (a) the number of shares purchased, (b) the purchase price, (c) the selling price, and (d) the amount of dividend per share. Your method should have the header: COSC 1436 CHPT 3 thod that will cosc 1436 CHPT 6 publie statie double profit (int shares, double buyPrice, double seilPrice, double dividend) in you Java main method, you are to ask the user to input the stock symbol, the number of shares, the purchase price, the selling price, and the dividends per share. The main method will then call the profit method to compute the profit and display the results. Your friend want the profit to always be displayed rounded to the nearest penny, but purchase price, sales price, and dividends can be in fractional cents.(Use a DecimalFormat object to do this. Your input and output should look like this: Input the stock's ticker symbol: BKEP Input the number of shares: 2200o Input the purchase price: 4.45 Input the selling pric: 4.35 Input the dividends paid: 0.145 SYOL SHARES BUY PRICE SELL PRICE DIVT DIENDS PROFTT 4.35 0.145 990.00 O Type here to search
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
