Results 1 to 2 of 2

Math Help - Computer programming

  1. #1
    Super Member
    Joined
    Feb 2008
    Posts
    535

    Computer programming

    My function will take a string parameter and return a double. It has to prompt the user to answer a question so the answer is a number. I don't know what to do. (Nothing can happen in main...only calls functions) Any advice? This is what ive got:

    double cost(string);

    int main()
    {
    cout << "Hello" << cost;
    }

    double cost(string)
    {
    cout << "Enter the cost of the item\n";
    cin >> cost;
    cout << "You entered " << cost << endl;
    }
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Apr 2008
    Posts
    1,092
    I would ask a question that has only a finite number of answers so that you can handle converting the string answers to doubles with a "switch" statement.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. How do i get LaTex on my computer
    Posted in the Math Software Forum
    Replies: 7
    Last Post: March 7th 2011, 02:21 PM
  2. Computer Science
    Posted in the Advanced Math Topics Forum
    Replies: 2
    Last Post: August 7th 2009, 06:06 PM
  3. Replies: 1
    Last Post: November 17th 2008, 04:18 AM
  4. Replies: 2
    Last Post: May 20th 2008, 03:02 PM
  5. Computer networking
    Posted in the Algebra Forum
    Replies: 1
    Last Post: August 11th 2007, 12:31 AM

Search Tags


/mathhelpforum @mathhelpforum