Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use java(OOP) Exercise - Stock Market Tracking Object - 1. o O 0 O 2. Create the Stock object class to store the data

image text in transcribedimage text in transcribed

Please use java(OOP)

Exercise - Stock Market Tracking Object - 1. o O 0 O 2. 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 previousChange 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). Add two new instance variables to the class: current Price, 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. 3. Exercise - Stock Market Tracking Object 4. O 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 currentChange amount using the following formula/algorithm: x = currentChange * 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 + currentChange Test your new method by creating a number of Stock objects and printing out O o 5

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions