2
answers
2
watching
227
views

Documentation & Requirements: 1. 5 pts. Write the file name, your name, email address and purpose of the program at the top of your source code in a
comment.
Example:
///////////////////////////////////////////////////////////////////////////////////////////////////
// Programmer: Thomas Gutierrez
// Email: [email protected]
// Purpose:
// Provides:
//////////////////////////////////////////////////////////////////////////////////////////////////
2. 5 pts. Add comments as appropriate throughout the program.
Program: 85pts.
This program will continue to build upon the Stocks Business Application program and transform it into a “Stocks” class. The
Assignment 5 solutions are recommended to be used as a starting point for this program. If the Assignment 5 solutions are not
used, refer to the Assignment 4 and 5 prompts for details.
The program must have the following requirements:
1. Create a Java Class named “Stock”.

2. The class should have at a minimum three private class variables:
o A variable for the stock name
o An array for the stock’s opening prices
o An array for the stock’s closing prices

3. This class should have two constructors:
o A “no argument” constructor.
o The parameterized constructor should take a parameter for the stock’s “name”.

4. Create the following set methods:
o setStockName: This method will initialize the stock’s name using the provided parameter               MGMT330 – Assigment 6, 2

o setOpenPrices: This method will initialize the stock’s opening prices along with its size based on the provided
parameters – open prices and number of prices.
o setClosePrices: This method will initialize the stock’s closing prices along with its size based on the provided
parameters – close prices and number of prices.

5. Create the following get methods:
o getStockName: This method returns the stock’s name
o getOpenPrices: This method returns the stock’s opening prices
o getClosePrices: This method returns the stock’s closing prices
o getDayPrice: This method returns the price for a specific day for either the opening or closing price of the
stock. Parameters include the day and which price to return, e.g. “O” or “C”

6. Create a method named “percentChange” that computes the percentage change between an opening day price and a
closing day price. This method should have two parameters: 1) the opening day to use; 2) the closing day to use.

7. Create a method named “averageStockPrice” that computes the average of a stocks open or close prices. This method
should take a parameter that determines whether to compute the average for a stock opening or closing prices: “O”
or “C”.

8. Create a method named “displayPrices” that will neatly display a stock’s opening and closing prices for a certain
number of given days. The method should have a parameter for the number of days to display.

9. In the program’s “main” method:
o Create two “Stock” objects named: GME and GOOG
o Initialize each of the stocks opening and closing prices as follows:
 GME:
Opening 96.57 94.05 90.14 116 141
Closing 96.13 89.15 115.17 128.46 137.21

 GOOG:
Opening 2388.59 2455 2287.46 2342.3 2351.56
Closing 2465 2390.12 2300.41 2388.23 2299.33

o Compute the change in price for GME for opening price day 2 and closing price day 4 and print it out neatly
to the user.

o Display all opening and closing prices for GOOG, and display the average of both types of prices.
Extra Credit:
5pts. Build another stock object with 10 open and close prices. Display all information about the stock: percent change
between the first price and final closing price, display all prices, average stock price for both types of prices. The object and its
information should be created and displayed at the end of the main program.               MGMT330 – Assigment 6, 3

Hints:
 All of Chapter 9 is useful for this program but the following sections cover the assignment: 9.2, 9.3, 9.4, 9.7, 9.9, 9.13
 Remember to indent your code properly.
 Scope will remain to be very important for variables when creating classes.

 Use previous assignment solutions for reference.

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in
Already have an account? Log in

Related questions

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in