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

  Write an ada program that will print your initials

Write an Ada program that will print your initials in large block letters, with each letter made up of the same character it represents.

  Assignment on combinational logic design

To design a logic circuit that will indicate whether a 4-bit binary input is exactly divisible by 3, 5. or 7. That is. the output will be a logic ' 1' when the input is divisible by any of the above 3 numbers, i.e. 3.5 or 7.

  What are some of the more popular exception handling uses

Exception Handling in Java is a very powerful capability. Exception Handling allows us to check input, verify if files exist, precent division by zero, prevent array out of bounds, and a whole host of other things.

  Which of the following is not a step in the post process

True or false? Every BIOS manufacturer uses the same flashing utility. What is the best source for BIOS updates? Which of the following is not a step in the POST process

  What is low level security

Using the school library, other credible sources and proper APA formatting write 6 pages on the following as they relate to physical security.

  Write the recurrence equation and initial conditions

Write the recurrence equation and initial conditions that expresses the execution time cost for the sift function in the above algorithm.

  Where qualitative and quantitative requirements can defined

It is claimed that in respect to subjects where qualitative and quantitative requirements can be defined, the quantitative alternatives should be preferred

  What are the five basic components of a computer

What are the five basic components of a computer? What is the difference between hardware and software? What are the two phases in writing a program?

  Research how windows virtual memory has changed

Research how Windows virtual memory has changed over the years. Cover at least 3 versions of Windows .

  Discuss the irony of his choices

Find examples in Chapter 2 "All American Boy," and the supplementary handouts, to describe how he looked at himself as if he were a white kid.

  Expalin the file system that will be installed

define the file system that will be installed in the server of your local hospital to support remote access of information by the hospital's doctors while they are using their mobile devices such as cellular phones or PDAs.

  Evaluate the business operations and network design

Write a 2 - 3 page paper evaluating the business operations and network design of your current organization or a previous employer (Preferably Retail Store but it is the Tutor's Choice).

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