Question: You are working on a data analysis project where you need to process an array of opening stock prices containing 1 0 days of data
You are working on a data analysis project where you need to process an array of opening stock prices containing days of data as float datatype.
Question:
Consider a scenario where you have been given an array of integers representing the daily stock prices of a company for a given period. You are also provided with an ArrayList of stock prices for the same period You are required to implement a program that performs the following tasks:
Calculate the average stock price:
Write a method, calculateAveragePrice, that takes the array of stock prices as input and returns the average price of the stocks.
Find the maximum stock price:
Write a method, findMaximumPrice, that takes the array of stock prices as input and returns the maximum price among all the stocks.
Determine the occurrence count of a specific price:
Write a method, countOccurrences, that takes the array of stock prices and a target price as input and returns the number of times the target price occurs in the array.
Compute the cumulative sum of stock prices:
Write a method, computeCumulativeSum, that takes the ArrayList of stock prices as input and returns a new ArrayList containing the cumulative sum of prices at each position.
Note:
Assume both the array and ArrayList of stock prices is not null and contains at least one element.
You are allowed to use loops for while for array and ArrayList.
Write the code for the above scenario, including the required methods and their implementations.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
