Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class exercise: Main assignment which linked to class exercise: please make a stock market tracking assignment(you do not need to make the simulator just hand

Class exercise:

image text in transcribed

Main assignment which linked to class exercise:

image text in transcribedimage text in transcribedimage text in transcribed

please make a stock market tracking assignment(you do not need to make the simulator just hand in me the code)
use the following stock information from yahoo finance
image text in transcribed
Exercise - Stock Market Tracking Object 1. Create the Stock object class to store the data for a single stock. The data shown gives 4 instance variables to begin with decide which data types to use for each. Use the following names for the instance variables: symbol stockName startingPrice e previous Change 2. Write a default constructor and a 4-arg constructor for creating Stock objects. Write get/set methods for each instance variable. Write a new toString method to help with testing. Test your object class by making a Tester class and using data from the table or pdf (which has more stocks to choose from). 3. Add two new instance variables to the class: currentPrice, currentChange where both are set to match the values of the starting Price and previousChange when an object is constructed (therefore a new 6-arg constructor is not needed). Add these to the toString method so they can be tested. Exercise - Stock Market Tracking Object 4. Write the updateStock method which takes no arguments and does not return a value. When called, the method simulates the passage of time during the trading day, where the currentPrice will be updated up/down by the current change amount using the following formula/algorithm: x = current Change - 15000 (truncated to make it an int; this is done so that there is a random chance that the stock will increase/decrease) r = random int 0.X OR X... (when x is negative if currentChange is negative) currentChange = (r = x/3)/10000 (to make it back into a double with 4-decimal-places) currentPrice = current Price + current Change Test your new method by creating a number of Stock objects and printing out + 5. In this assignment you will design, write and test a complete Java object class (which we began in class) along with a driver program to simulate how stocks change in value over time. How the stocks perform over time is randomized rather than using real daily data or live data. The beginning stock data is taken from actual, recent data from January 16th. Assignment Tasks 1. Add to the Stock object class that was started in class (make sure that it is completely working before starting the assignment of course) by adding the printTableEntry method. This method takes no arguments and does not return anything. The printTableEntry method simply uses the data held within the instance to simulate the information shown in the table below, to print out the following information for the stock: AAPL Apple Inc. 173.07 +0.88 +0.51% Symbol - code/letters representing the stock (use a field so that everything will line up in columns like a table) Stock Name - full name of the company/stock (use a field so that everything will line up in columns like a table) Current Price - the current price of the stock (not the starting price at the beginning of the trading period) formatted to two decimal places (use a field so that everything will line up in columns like a table) Current Change - the current change in the price of the stock (not the previous change in price from the previous day of trading) formatted to two decimal places including the +/- to show if the stock is currently increasing or decreasing (use a field so that everything will line up in columns like a table) Percent Change - calculate this value from the difference between the Starting Price and the Current Price for the stock, and print the value formatted to two decimal places including the +/- to show if the stock is currently increasing or decreasing, and the %-sign afterwards (use a field so that everything will line up in columns like a table). Note - when your program begins, there is no difference between the starting and current prices so this will initially display as =0.00%. - To handle the formatting of text (in fields padded with spaces) and real numbers (to two decimal places) you will need to use System.out.print() along with formatting commands to control the output. Reading - have a look in the Big Java textbook at section 4.3.2 Formatting Output which outlines how to format different kinds of output and use text fields so that your output will line up into columns. Note - the printf command does not start a new line of output (printin has to be called separately, which you should do at the end of this method). Test this new method by creating a bunch of stocks, updating all of their prices and then calling printTableEntry for each stock to see how they appear together the different text and values should all line up into columns). 2. Add another method to the Stock object class called closeOfTrading. This method takes no arguments and does not return anything. The closeOf Trading method simply updates the instance variables of the object, which is done at the end of the day when the stock markets close. The method should make the following changes: Starting Price - is reset to the Current Price (the current price of the stock at the end of the day becomes the new starting price for the next day of trading) Previous Change - is reset to the Current Change (ready for the next day of trading) 3. Change the updateStoek method in the stock class to make the volatility of the stocks a little more varied by doing the following: In the formula for calculating currentChange, it divides x by 3 - currentChange = (r-x/3)/10000 Instead of always dividing by 3. change this calculation so that it divides by a random number in the range 1..5 (where 3 is the middle ground) 4. Create a new driver program which simulates tracking the stocks you have chosen to model over a period of time (measured in days). The driver program will display the chosen stocks as they start the simulation, and their values after each day of trading, as follows: Use the data shown in the pdf list of stocks (on Brightspace) to instantiate a list of stocks to use in your simulation. Include Apple (AAPL) and Zynga (ZNGA) plus any other stocks shown in the pdf, to give at least 20 stocks total. Prints out a complete table showing the starting values of all stocks in your list for Day O (before any changes have occurred). The starting prices and previous change values shown should match what is shown in the pdf document Asks the user for the number of days to run the simulation for (where 5 is a full week of trading, and 20-23 would be a full month) Run the simulation for the number of days given, where each day is labelled/printed out, and the following methods are performed on each stock: - update Stock - print Table Entry - closeOfTrading 5. Test your program thoroughly to make sure that all of the methods work properly and that the score is kept accurately. Use your testing plan to make sure you are confident that it works. Once you are satisfied that your program is working properly, you will hand it in by making a screencast video of your code and you acting as the user demonstrating your program. To make a screencast video use one of the following options: Quicktime Player - Macs only (File > New Screen Recording) Screencastify - Chrome extension (free) Screencast-o-matic - download and install the free version When making your screencast recording use the following rules and include the following: A Length - total video must be under 3 minutes in length B. Display - clearly show your Java code and output (see below), scrolling through your program to show its structure, programming style and proper indentation C. Voice - yes, you will need to talk (in English) over your video while you are recording, recommend using a headset with a microphone to record your voice clearly and to help reduce outside noise (record in a quiet place please) D. File Type and File Size - record and submit as an mp4 or mov only please (aviflv files and uploading to YouTube will not be accepted). If you are prevented from uploading your video due to file size then you have to edit/trim the video, save it as a different file type, or compress the video file to make it smaller. The other option is to re-record the video and make it shorter in length E. Include the following: - Introduce yourself with your name and student number - Scroll through your Java code (showing your driver program and object class structure/methods, correct indentation, programming style and use of naming conventions) - Describe the hardest part of making these programs for you - Demonstrate that your program works by running it at least twice and scrolling through the output each time, using the same list of stocks and the following input values i. 5 days of trading 20 days of trading ii. Are Most Active han for Sed WWE MO 1 sale WA .. Low # 4.12 WWW TER 1 V A ILM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions