Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume you are working on a data analysis project where you are required to process a collection of opening stock prices with 1 0 days
Assume you are working on a data analysis project where you are required to process a collection of opening stock prices with days of data as float datatype.
Question:
Take into consideration a scenario where you have been given an array or a collection of integers representing the daily stock prices of a company for an agreed period. You are also provided with an ArrayList of stock prices for the same period. You are obligated to implement a program that performs the following tasks:
Calculate the average stock price:
Write a method, calculate AveragePrice, that takes the array of stock prices as input and returns the average price of the stocks.
Find the maximum stock price:
Write a procedure, 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 procedure, 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.
work out 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:
Make an assumption that both the array and ArrayList of stock prices is not null and contains at least one element.
You are permitted to use loops for while for array and ArrayList.
Write the code for the above scenario, including the required methods and their implementations.
Remember to use appropriate variable names and follow coding best practices.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started