Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java Program that does the following: File Link - https://www.dropbox.co

ID: 3822603 • Letter: W

Question

Write a Java Program that does the following:

File Link - https://www.dropbox.com/s/tpyvapym5t8xx80/Data.csv?dl=0

Once you are done paste the Java Code with a Picture of the Output as the answer to this problem. Many Thanks and have a wonderful day!

Problem The stock market generates a massive amount of data each day, so much so that computerized methods are required to manage the volume. You are asked to write a program that uses real data to evaluate a stock. Requirements Write a Java program that will read and analyze the provided real stock price data and determine the maximum profit possible based on buying at a low price and selling at a high price The program will read data from a file called "Data csv" to retrieve the date and value per share (adicose). The only columns of interest in this comma separated value file are the first and the last columns: the "Date" column and the "Adj Close" column respectively We can find the profit per share by searching through the closing share values and finding the largest positive difference between a pair of values. Obviously, the shares must be bought before they can be sold. The profit realized between any two days is computed as the difference between the later share value and the earlier share value. You will note that the file is arranged by date starting with the latest values and going back in time output You are required to output only the buy and sell dates and the profit per share that could have been realized for making the best possible trade. For example, given the small subset of the data shown here Date Open High Low Close Volume Adi Close 3/4/2017 831.36 835.18 829.036 834.57 1044400 83 4.5 4/3/2017 82 9. 22 840.85 829.22 838.55 167 0200 838.55 3/31/2017 328.97 831.64 827.39 829. S6 139 700 329. S6 833. 831.5 1052800 831.5 3/30/2017 833.5 68 829 332.765 822.38 831.41 1796200 831.41 3/29/2017 825 3/28/2017 320.41 825.99 314.027 320.92 1618000 320.92 3/27/2017 80 6.95 821.63 803.37 819.51 E1894300 819.51 3/24/2017 320.08 321.93 308.89 814.43 1970900 814.43 822.57 812. 257 817.58 3483800 817. 58 3/23/2017 821 Would result in and output of The maximum profit. occurs between 3/24/2017 and 4/3/2017 and is $24.12 per share

Explanation / Answer

/**
* VI336563
* TODO
*/
package com.vimal.graph;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

/**
* @author VI336563
*
*/
public class transmitter {
  
   public static void main(String args[]){
       try
       {
       //Scanner sc = new Scanner(System.in);
       //String input1 = sc.nextLine();
      
       String csvFile = "D:/demo.csv";
       String line="";
       TreeMap<Double,String> data = new TreeMap<Double,String>();
       BufferedReader br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {

   String[] starr = line.split(",");
   data.put(Double.parseDouble(starr[6]),starr[0]);
}

Entry<Double,String> firstEntry = data.firstEntry();
Entry<Double,String> secondEntry = data.lastEntry();
double profitPerShare = secondEntry.getKey()-firstEntry.getKey();
System.out.println("The Maximum profit occurs between the 3/24/2017 and 4/3/2017 and is $24.12 per share");

      
       }
       catch(Exception e)
       {
           e.printStackTrace();
       }
      
   }

}

output--

The Maximum profit occurs between the 3/24/2017 and 4/3/2017 and is $24.12 per share

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote