Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

anyone who does c++,please help!

  • 14-02-2006 7:57pm
    #1
    Closed Accounts Posts: 8


    assignment
    14 February 2006 (HT wk 6)
    Objectives: Program development with stubs
    Task:
    Write a program to compute the total value of a portfolio of shares and percentage
    gain since purchase, as well as details of each share holding. A possible interaction of
    this program is shown below. Because you don’t know how to obtain the price of a
    particular share on a given date, you should use a stub function for this, which
    provides the following interface:
    double get_price (string companycode, int day, int month, int year)
    /* returns the price in cents of a share in the company identified by */
    /* companycode on the date (day, month, year) on the Irish Stock */
    /* Exchange*/
    Your stub for get_price() might initially return a fixed value in all instances. However
    to allow more extensive testing of your program, get it to return a price based on
    adding the day, month and year, (e.g. get_price (“BOI”, 3, 7, 2005) returns 2015) or
    use a series of IF statements to return different prices for a few different company
    codes, possibly affected by dates too.
    Your program should also use functions to read details of each holding (perhaps from
    a file instead of from the keyboard), to output details of each holding, to compute
    values of holdings (this function should call on get_price()), and wherever else you
    feel a function might be appropriate.
    Notes – Strings:
    Even if we haven’t covered strings yet, for this program you just need to be able to
    declare a string variable and parameter, to read in and write out strings, and to test if a
    string variable is equal to a string constant. All these things are as you would expect.
    As long as you are only trying to read in a string that has no spaces in it
    cin >> my_string;
    works fine.
    Sample interaction (but don’t feel totally constrained by this):
    Enter a company code, and number of shares held: BOI 100
    Enter the day month and year of purchase of these shares: 3 7 2005
    100 BOI purchased for £2015.00, today worth £2022.00, gain of 3.47%
    Do you have more shares? Y
    Enter a company code, and number of shares held: FFA 350
    Enter the day month and year of purchase of these shares: 22 11 1999
    350 FFA purchased for £7112.00, today worth £7077.00, loss of 0.5%
    Do you have more shares? N
    Total purchase price was £9127.00.
    Current value is £9099.00.
    Loss since purchase of £28.00 or 0.3% of £9127.00


Comments

  • Closed Accounts Posts: 4 Vengeance Puppy


    So what part of this is causing you the problem? I presume that you'd be able to write most of the program yourself and have only bits left that you don't understand how to implement...


  • Closed Accounts Posts: 296 ✭✭PDelux


    Maybe this should be in Computers/Programming?


Advertisement