Represent a single stock in someones investment portfolio

Assignment Help Computer Engineering
Reference no: EM132196992

Write a class StockHolding. The purpose of a StockHolding object is to represent a single stock in someone's investment portfolio.

The StockHolding class has the following specification:

instance variable of type String for the ticker symbol of the stock instance variable of type int for the number of shares held instance variable of type double for the initial price of one share instance variable of type double for the current price of one share constructor StockHolding(String ticker, int numberShares, double initialPrice) // current share price is initialized to the same value as initialPrice accessors String getTicker() int getShares() double getInitialSharePrice() double getCurrentSharePrice() double getInitialCost() // number of shares * initial price double getCurrentValue() // number of shares * current price double getCurrentProfit() // number of shares * (current price - initial price) String toString() // returns "stock <ticker>, <number of shares> shares bought at <initial price>, current price <current price> mutators void setCurrentSharePrice(double sharePrice)

Below is class StockHoldingMain that contains main() method that should be used to test your program.

public class StockHoldingMain {

public static void main(String[] args) {

StockHolding apple = new StockHolding("AAPL", 19, 103.97);

StockHolding ibm = new StockHolding("IBM", 10, 160.8);

StockHolding oracle = new StockHolding("ORCL", 25, 40.76);

System.out.println("apple initial cost: " + apple.getInitialCost());

System.out.println("ibm initial cost: " + ibm.getInitialCost());

System.out.println("oracle initial cost: " + oracle.getInitialCost());

apple.setCurrentSharePrice(105.5);

ibm.setCurrentSharePrice(150.1);

oracle.setCurrentSharePrice(45.5);

System.out.println("apple profit: " + apple.getCurrentProfit());

System.out.println("ibm profit: " + ibm.getCurrentProfit());

System.out.println("oracle profit: " + oracle.getCurrentProfit());

System.out.println(apple.toString());

System.out.println(ibm.toString());

System.out.println(oracle.toString());

}

Reference no: EM132196992

Questions Cloud

Write a class that keeps track of the top five high scores : Write a class that keeps track of the top five high scores that could be used for a video game.
An instance variable named amount of type double : A method named useGas that accepts a parameter of type double . The value of the amount instance variable is decreased by the value of the parameter .
Calculates and returns the current income amount : Two (2) instance variables a double called "IncomeYTD" and double called "hourlyRate" The class should also include the following methods.
Write a client program that allows the user to pick one : Write a client program that allows the user to pick one of your three spell checkers (the unbalanced BST, the balanced BST, or the trie).
Represent a single stock in someones investment portfolio : Write a class StockHolding. The purpose of a StockHolding object is to represent a single stock in someone's investment portfolio.
Write a class teacher that contains the attributes teacher : Write a class Teacher that contains the attributes teacher name and address. It also contains member functions to input and display its attributes.
Calculate the logarithmic mean temperature : Derive the performance equation for an ideal PFR - Derive the performance equation for an ideal CSTR - What would you recommend to management with regard
Write a class encapsulating the concept of a license plate : Write a class named CarPlate encapsulating the concept of a license plate, assuming that it has the following attributes: the plate number, the state.
Define exception and throw when the fraction is instantiated : Write a class Fraction, define a exception and throw when the fraction is instantiated with zero in the denominator.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Maintain planar motion

Describe how the mechanism is designed in order to maintain planar motion.

  How much of companys network capacity are employee consuming

How much of the company's network capacity are employees consuming when watching YouTube videos?

  Declaring a variable using the public, friend, or private

In visual basic.NET, what makes up a component? What are the advantages of components? In addition, what are the types of class data and how do you decide which is appropriate? describe the difference between declaring a variable using the keyword..

  Describing the company including the business

Completely describe the company including the business and where the company located. Determine the minimum services that must be maintained for that company.

  What are seven basic step in reviewing computer-based system

What is the preliminary review portion of an audit and why is it important? What are the seven basic steps in reviewing computer-based systems?

  Define a class for a type called fraction

Define a class for a type called Fraction. This class is used to represent a ratio of two integers. Embed your class in a test program.

  Describe the ongoing maintenance that will be required

Describe the ongoing maintenance that will be required. Provide a workflow diagram in Visio or equivalent software to illustrate how the system will work.

  Geographic information system for storing point data

For this project you will build a simple Geographic Information System for storing point data. The focus is organizing city records into a database for fast search. For each city you will store the name and its location (X and Y coordinates). Sear..

  Calculate the accumulated sample error for one character

Suppose that a remote transmitter sends a message at 2500 Baud and the receiver is expecting the data rate to be 2400 Baud.

  What kind of compression function is used in whirlpool

List some features of the Whirlpool cryptographic hash function. What kind of compression function is used in Whirlpool?

  Are there any other examples of famous projects

Are LANs a stable technology or are they changing just as fastly as other forms of communication technologies?

  Write a program to convert time in days and hours

He wants you to write a piece of code that prompts the user for number of days, hours, minutes, and seconds (in that order).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd