Question: In Java Part 2: Complete the below RunStock class, which has a main method. Here, we will create objects of the Stock class and demonstrate

In Java

Part 2:

Complete the below RunStock class, which has a main method. Here, we will create objects of the Stock class and demonstrate how to initialize its attributes and compute the cost of purchasing a stock. Create 2 objects of the Stock class one will have the attributes preset in the main method, and the other will have the attributes entered by the user). For each stock, the program should display all the stock information, ask the user how many shares he/she will like to purchase, and display the cost of purchasing the stock.

[When dealing with user input, consider what error checking we should put in place, i.e. no negative values] [Use formatted output, 2 decimal places, for currency] [Consider that company names may be more than one word]

As sample data, for the company Apple, we can have the following stock information:

Stock symbol:AAPL

Company name:Apple Inc.

Stock price: 130.90

and for Google, we have:

Stock symbol: GOOG

Company name:Alphabet Inc.

Stock price:2001.00

RunStock.java publicclass RunStock {

publicstaticvoid main(String[] args) {

}

}//end of RunStock class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!