Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework - Stock and Random classes: Design a class named Stock that contains: A string data field named symbol for the stock's symbol. A string

image text in transcribed
image text in transcribed
Homework - Stock and Random classes: Design a class named Stock that contains: A string data field named symbol for the stock's symbol. A string data field named name for the stock's name. A double data field named previousClosingPrice that stores the stock price for the previous day. A double data field named currentPrice that stores the stock price for the current time. An integer data field named ID that stores the identifier number of stock. A constructor that creates a stock with the specified symbol, name, and ID. A method named getChange Percent() that returns the percentage changed from previous Closing Price to currentPrice. Draw the UML diagram for the class and then implement the class. Write a test program that creates a Random object from the Random class (java.util. Random). -We will use this object for the ID number of Stock between (0 to 100)- asks a user for the name and symbol of Stock. So, you should create two string variables in the test program. creates a Stock object with the stock symbol (from the user), the name of symbol (from the user), and ID (from Random object by using nextint(100) method). asks the user for the previous closing price and the current price. Note: Don't create two variables for them. You can use the stock object to assign the values of these two variables from the user. finally, displays the stock name, the stock symbol, the stock ID, and the price change percentage. Here is the simple run: Enter the name of Stock: Oracle Corporation Enter the symbol of Stock: ORCL Enter the previous closing price: 34.5 Enter the current price: 34.35 Stock name: Oracle Corporation Stock symbol: ORCL Stock ID: 59 Price-change percentage: -0.434782608695648

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

why NH 3 is more basic than PH 3

Answered: 1 week ago