Converting English to Metric and vice versa via pass-by-reference void function.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • socondc22
    New Member
    • Sep 2007
    • 67

    Converting English to Metric and vice versa via pass-by-reference void function.

    Im stuck at this point. The way i was trying to do this was running if statement around my void function and then a else if statement around a different void function but it didnt work... right now i deleted part of what i had but left my skeleton of it there...

    [CODE=c] #include <iostream>
    using namespace std;
    void get_numbers(dou ble& input1, double& input2);
    void show_results(do uble output1, double output2);

    int main()
    {
    char letter;

    cout<<"Metric to English and English to Metric converter.\n"
    <<"For Metric to English type m, for Enlish to Metric type E, Type q to quit.\n";
    cin>>letter;

    double first_num, second_num;

    get_numbers(fir st_num, second_num);
    show_results(fi rst_num, second_num);
    return 0;
    }


    void get_numbers(dou ble& input1, double& input2)
    {
    using namespace std;
    cout<< "Enter first number as meters and second as centimeters.\n" ;
    cin>> input1
    >> input2;
    input1 = input1 * 3.2808399;
    input2 = input2 * .393700787;
    }

    void show_results(do uble output1, double output2)
    {
    using namespace std;
    cout<< "Feet: "<<output1< <" Inches: "<<output2<<end l;
    }
    [/CODE]
    Last edited by pbmods; Oct 14 '07, 07:35 PM. Reason: Changed [CODE] to [CODE=c].
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by socondc22
    The way i was trying to do this was running if statement around my void function and then a else if statement around a different void function but it didnt work...
    I can't see what your difficulty is when you have deleted the code that caused it.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, socondc22.

      What do you want your code to do? Give an example.
      What is your code doing that you don't want it to do? Give an example.
      What is your code *not* doing that it is supposed to? Give an example.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        @OP: please don't start two or more threads on this very same topic.

        kind regards,

        Jos

        Comment

        Working...