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

  Explain the difference between clustering and classification

Explain the difference between clustering and classification. Explain the reason behind describing artificial neural networks (ANN) as black box.

  Write a program that prompts the user to input the lengths

Write a program that prompts the user to input the lengths and widths of the door, each window, the bookshelf, and the length, width, and height of the room.

  How can technology expert detect the signal

How can technology expert detect the signal for a potentially transformative discovery. The response must be typed.

  Give the declaration for two variable called feet and inches

Give the declaration for two variables called feet and inches. Both variables are of type int and both are to be initialized to zero in the declaration.

  How many frames per second do a T-one and SONET transmit

How many frames per second do a T-1 and SONET transmit? Why this number?

  Determine which cpu of the given two is faster and why

Determine which CPU of the two is faster and why. Conclude whether or not the clock rate by itself makes the CPU faster. Provide a rationale for your response.

  Write a program for the standard deviation

Write a C++ program. PLEASE FOLLOW INSTRUCTIONS EXACTLY. This program takes its inputs from a file that contains numbers.

  Implement the topological sorting algorithm

Implement the topological sorting algorithm. Implement Kruskal's algorithm assuming that the edge weights are integers.

  Define a classes named ExamStatistics

CS160 - 01/02 Project - Examination Statistics Assignment. Design - For this project you shall define a classes named ExamStatistics

  Demonstrate the ability to assemble already-written classes

CSC151 : Demonstrate the ability to assemble already-written classes into a larger, more complicated program.

  Implement the remaining relational operators

Implement the remaining relational operators. Modify constructor for fraction class that it checks to make sure that numerator and denominator are both integer.

  Discuss which approach gives better results

Run the kNN algorithm on the given set. ( it should be around 53% accurate ). Run naive Byes code on the same data. Discuss which approach gives better results.

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