Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA CODE! Part A: Arrays of Objects Write a Stock class that has three data members - name (string), price (double) and volume (int). This

JAVA CODE!

Part A: Arrays of Objects

Write a Stock class that has three data members - name (string), price (double) and volume (int). This class should have a constructor with three parameters (string, price, and volume).

Create a text file stock.dat and type in description of different stocks, one per line where the first four letters is the name of the stock, the next real number is the price of the stock, and the last number is the volume of the stock (the number of stocks available for purchase).

MSFT 36.5 200000

FAST 45.5 500500

Write an application that reads the text file stock.dat and creates stock objects - one per line. Then the application a) selects and prints the stock that has the lowest price, b) the stock that has the highest price, and c) the stock that has the lowest volume.

The application then asks the user to type in the name of a stock upon which it finds the stock in the array and outputs the stock information as shown below. (If the stock name is not found an error message is output.)

The stock MSFT is priced at $ 36.50. There are 200000 stocks available.

The file can contain any number of stock description but no more than 100.

Part B: Updating Objects

The application asks the user to choose a transaction - BUY or SELL. Then requests information for the transaction - a stock name, number of stocks, and the price for the transaction. It then updates the stock object example - reduces the stock volume by the number of stocks bought and sets its prices with the price of the transaction.

Verify the update with by requesting information about the stock as in part A.

The user should be able to repeat the buy/sell option until chooses to quit.

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago