Results 1 to 2 of 2
  1. #1
    Avey is offline Member
    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0

    Question I need help on a simple java assignment

    Hello, I am new to java and need help getting started on writing this program. These are the assignment's given instructions.


    A stock is first offered to the public at a start-off stock-price. The initial offering also comes with an initial volume (or number of stocks). Every stock is identified by a stock symbol – which is a string. Then, the stock market takes over and the stock-price fluctuates with the buying and selling of the stock.

    Write a Stock class. It should have a constructor which requires a stock symbol (string), an initial volume (int), and an initial stock-price (double). Other than the getters and setters, the operational methods required for the Stock class are –

    Name Parameters Purpose of the method

    Buy number, new price decreases the volume by number and sets the stock-price to the new price
    Sell number, new price increases the volume by number and sets the stock-price to the new price
    toString none Returns a printable string with - volume and price, and total value of the stock

    Write an application (call this class – Broker). The broker class acts as a buyer and seller of stock for a client. This application should

    Request a symbol, initial volume, and start off price for one stock from the user and create a Stock object with this information in it.

    Output the current state of this Stock object.

    Request the name of client and their initial money.

    Outputs the portfolio of the client - the name, the initial money held, and the number of stocks held.

    Then, it presents an option to buy the stock. Based on user response, for volume and price – the stock is bought for the user. The
    broker adjusts the client portfolio.

    Then, it presents an option to sell the stock. Based on user response, for volume and price – the stock is sold for the user. The broker adjusts the
    client portfolio.

    (Note that the number of stocks bought cannot be more than the initial volume; and cannot sell more than that has been bought)

    Finally output the current state of the Stock, and the user portfolio.

    Ex: User inputs the symbol “MYSTK” initial volume as 10000, and starting price as $ 8.00.

    User inputs the client name as “Iyengar” and client’s money as $ 50000.
    Output of Current State:
    Symbol MYSTK
    Volume 10000
    Price $ 8.00
    Value $ 80000.00

    User selects Buy
    User inputs Volume 1000
    Price 8.25

    User selects Sell

    User inputs Volume 500
    Price 8.50

    Output of Current State:
    Symbol MYSTK
    Volume 9500
    Price $ 8.50
    Value $ 80750.00
    Stocks held by Broker:
    Client Name: Iyengar
    Client Money $ 46000
    Symbol MYSTK
    Volume 500
    Price $ 8.50
    Value $ 4250.00

    Total Value: $ 50250.00

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: I need help on a simple java assignment

    I see there's a copyright notice at the top of Copyright © – Sudharsan Iyengar and Winona State University . Do you have the author's permission to reproduce the content here?

    Also, don't expect anyone here to do your homework for you. If you have a specific problem or question, you're sure to get help. See How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Java Assignment
    By MichaelF144 in forum New To Java
    Replies: 34
    Last Post: 04-24-2012, 05:28 PM
  2. java assignment
    By Tuz in forum New To Java
    Replies: 28
    Last Post: 02-16-2012, 08:39 PM
  3. Question about a simple Java programing assignment.
    By ron_j_m in forum New To Java
    Replies: 12
    Last Post: 04-27-2011, 12:03 AM
  4. java assignment
    By omgonoes in forum New To Java
    Replies: 13
    Last Post: 04-23-2011, 02:29 AM
  5. Replies: 4
    Last Post: 11-02-2009, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •