Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CIT 239 Java Programming Lab Exercise 9a Stock class Due Date You must demonstrate the solution to this lab exercise to the instructor by Sunday,

image text in transcribed

image text in transcribed

CIT 239 Java Programming Lab Exercise 9a Stock class Due Date You must demonstrate the solution to this lab exercise to the instructor by Sunday, March 12, 2017, in order to receive credit for this work. Stock Class This lab is adapted from Programming Exercise 9.2, on page 360 of the Liang textbook. Lab Exercise The Stock class: Following the examples of the CircleWithPrivateDataFields class in Section 9.9 and TestCircleWithPrivate DataFieldsjava (also in scction 9.9), design a class named Stock that conlains A string data field named symbol, for the stock's symbol A string data lield named name, for the stock'sname 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 "Getter" and "Scttcr" methods for each of the data fields get Symbol0, setSymbol0, getName0, setName0, get PreviousClosingPriceo, setPreviousClasingPrice0, get CurrentPrice0, setCurrentPrice A constructor that creates a stock with a specified symbol and name A method named getChangePercent0 that returns the percentage changed from previousClosingPrice to currentPrice. Write a test program that prompus uhe user for a stock symbol. If the user enters "q", then the program should exit. If the user enters anything other than "q", then the program should assume that the input represents a stock symbol After a stock symbol is input, the program should prompt the user for the company name associated with thc stock symbol, and also the company's previous closing price and current price. The program should create an instance of the Stock class, and utilize the appropriate set methods to set the object's internal field values. After the object is created and its member variables are set, the program should call the getChangePercento method to determine how much the stock price has changed. When this processing is finished for one stock, the main loop should ask the user for another stock symbol, and repeat the process. The program exits when the user enters the string "q" in place of a stock symbol Your program should have two classes: a public class named Lab9a, and another (non-public) class named Stock. The Lab9a class contains amain method, which creates an object ofthe Stock class CIT239-SU Lab9a Stock 20170219 docx 2/18/2017 8:42 PM

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 Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago