Represent a single stock in someones investment portfolio

Assignment Help Computer Engineering
Reference no: EM132137113


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());




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

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

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






Reference no: EM132137113

Finds would cause damage to national security

Write review on this. Today in order to make face the increasing rate of data breaches in the companies, there is widespread agreement about the interests of participants

Prepare a detailed design document for the user interface

Prepare a detailed design document for the user interface for your project. Your design document should be based on your Project Requirements and Scope document and your Pro

Fuzzy system for forecasting electricity price

A Fuzzy System for Forecasting Electricity Price - Develop a fuzzy forecasting system using Matlab Toolbox. The system performs a forecasting task for power marketing price.

Write the boolean function as boolean algebra

Write the Boolean function as Boolean algebra terms. First, think about how to deal with the two outputs. Then, describe each single row in terms of Boolean al

Developing programs via functional decomposition and pointer

CSCI251/851 Advanced Programming Developing programs via functional decomposition and pointers.On completion you should know how to design a program by decomposing the problem

3d animation using in object modelling and methods

Ngaruwahia Golf Course sits on the banks of the mighty Waikato River. This club is an easy 10 minutes' drive north of Hamilton and an hour's drive south of central Auckland

Implement a prototype

KIT205 Data Structures and Algorithms - Assignment 1: Data Structures Implement basic program functionality for a console driven application - Implement and test a linked list

Implementation of the spacecraft feature

Assignment 1: The Diamonds of Doom - Discuss and brain-storm with your associates, you must ensure that your submission is your own individual work - implementation of the "Sp


Write a Review

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