Represent a single stock in someones investment portfolio

Assignment Help Computer Engineering
Reference no: EM132137113

StockHolding

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: EM132137113

Questions Cloud

Write a gui program that will allow a user to buy : You are to write a GUI program that will allow a user to buy, sell and view stocks in a stock portfolio.
What is stp and rstp : What is STP, what is RSTP, and what methods does Cisco provide to make these two methods work better as networks grow?
Additional land and build a new assisted living center : Suavo breeze would like to buy some additional land and build a new assisted living center. The anticipated total cost is $23.6 million. The CEO of the firm
What is the corporate bond market : What is the Corporate Bond Market, and what are key differences between the bond and stock markets?
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.
Common stock and debt of chen inc : The common stock and debt of Chen Inc are valued at $75 million and $25 million, respectively. Investors currently require a return of 16.1% on the common stock
Forward hedge or a money market hedge : Would it be better off using a forward hedge or a money market hedge? Provide the mathematical analysis to justify your position.
Calculate the costs of buying versus leasing a motor vehicle : Calculate the costs of buying versus leasing a motor vehicle.
Create a parallel plane in the synchronous part environment : create a parallel plane in the Synchronous Part environment. Apply the crown by defining its radius and take-off angle.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Make a c++ program containing a class fraction

construct a C++ program containing a class Fraction. The class data should have two variables numerator and denominator, both of type integer, to represent the fraction numerator/denominator.

  Create an initial researched and cited discussion response

Create an initial researched and cited discussion response early in the week about the topic you choose and follow with at least two researched.

  Create a web page about your favorite musical group

Create a Web page about your favorite musical group. Include the name of the group, the individuals in the group and a hyperlink to the group's Web site.

  Give an efficient algorithm for computing the diameter of t

The time delay of a long-distance call can be determined by multiplying a small fixed constant. Give an efficient algorithm for computing the diameter of T.

  Draw toplevel data flow diagram for fiat for football method

Draw a Context Diagram for the FIAT for Football process. Draw a top level Data Flow Diagram for the FIAT for Football method. Blow up any one non-trivial process into a first level Data Flow Diagram.

  Process of formulating an entry strategy

Describe the process of formulating an entry strategy. The answer requires to be at least 300 words. Also include any of the references.

  Fraction insimplest form

A spinner has5equally sized sections,3of which are gray and2of which are blue. The spinner is spun twice. What is theprobabilitythat the first spin lands on gray and the second spin lands on blue ? Write your answer as a fraction insimplest form.

  Sequence of actual mips instructions

use a sequence of actual MIPS instructions to implement the similar behavior.

  Make a list of files that are world-writable

make a crontab to perform the tasks listed below at the frequencies specified. Note that you do NOT need to write the actual scripts.

  Writa a paper based on system failure

Writa a paper based on system failure: Faster system processors, Software and hardware compatibility, High system capacity, Information system policies, Security system, and High reputation for software and hardware vendors.

  Describe how osi model layers can effect a network design

There are two different types of switching technologies available in today's market. One lives on one layer, while the other resides in a different layer.

  Compare and contrast two distinctly different

compare and contrast two distinctly different organizations on how they use information systems in their organizations.

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