Answered step by step
Verified Expert Solution
Question
1 Approved Answer
confused on Question 1 Files For this project, you will create an Online Stock Market using what you have learned about classes and objects. This
confused on Question 1
Files For this project, you will create an "Online Stock Market" using what you have learned about classes and objects. This online stock market should offer stocks for at least three companies. As an example, I created an online stock market that sells Apple, Google and Microsoft stocks. I created three different classes in my project, one for each type of stock, as can be seen in the image below from the NetBeans Project window: Projects x Services Stock MarketProject Source Packages stockmarketproject Apple.java Google.java Microsoft.java Stock MarketProject.java Test Packages Libraries Test Libraries You can use Investopedia to look up stocks To use Investopedia, type in the name of a company in the search box, for example: Austel AAPL APPLE INC APLE APPLE HOSPITALITY REN INC If there is more than one option, choose the company you wish to include in your program from the menu. This will bring you to a page with detailed information about the company's stocks. On the left hand side of the web page you will see the information included in the image below: The price given on the left is the cost of one "share" of MARKETS TODAY the stock. A share is the term used for one unit of a company's stock. In this case, one share of Apple stock costs $174.92 in U.S. dollars. So, if you spent $349.84 on this stock, you would own two shares APPLE INC of Apple stock. The stock symbol for Apple is AAPL" which can be seen in the image above, and the image AAPL NASDAQ to the right. Stock symbols are used to identify companies on the stock market. 174.92 is -4,781-2 Part 1 - The Classes: Create (at least three classes, where each class represents one company's stock. Each class should have the same three fields: A String stock symbol field to store the symbol for the company on the stock market. For example, Apple's stock symbol is AAPL" and Microsoft's stock symbol is MSFT" A double cost field to store the price of one share of the stock An integer field to store the number of shares the user currently owns of that stock Create a no-arg constructor and set the initial number of shares owned to 0, and the cost and stock symbol to the correct values from the Investopedia website. Also, create an argument-based constructor to allow the three fields to be initialized in the main method when the object is created. Create getter and setter methods for each of the three fields. Also, create the following methods: An addShares void method that takes an integer and adds it to the field that currently stores the total number of shares the user owns of that stock A removeShares void method that takes an integer and subtracts it from the field that currently stores the total number of shares the user owns of that stock A calcStockValue method that calculates and returns the total value of all the shares owned of that stock (e.g. if two shares of Apple stock are owned, this method should return 349.84) Include a toString method that prints out a user-friendly message displaying the three fields. Please submit a UML Diagram for one of your three classes when you hand in your project. Part 2 The Main Program: Create one object for each class at the beginning of your main method. You can use either the no-arg constructor or the argument-based constructor. Welcome the user, then begin a do-while loop with a switch, displaying the following menu: 1. Buy stock 2. Sell stock 3. View your stock portfolio 4. Exit program If the user chooses option 1, ask them how many shares of each stock they would like buy and add their input to the field that stores the total number of shares for that company's stock. If the user chooses option 2. ask them how many of each stock they wish to sell, and subtract each amount from each shares field. If the user chooses option 3, display a well-aligned chart summarizing the value of their stocks (please refer to the example on Page 4). If the user chooses option 4, the program should end, print a goodbye message, and call the toString() method for each object to summarize the number of stocks the user owns for each company. If the user chooses an option not in the menu, print an error message. Finally, for a thinking mark, you will need to include one extra feature for your program that is not mentioned above (for example, error traps for the user input, an option to convert the value of the stocks to Canadian dollars, an extra method that performs a function not mentioned above, and so on). Please include a program header for each file, I/comments, and method headers in each classStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started