Thread: Debug Conversion program

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    Debug Conversion program

    Could someone pleasee help me debug this program..Its for converting meters-cm to ft-inches and vice versa and adding the 2...
    __________________________________________________ _________________
    Code:
    #include
    #include
    class db;
    class dm
    {
    float m;
    public:
    void getdata()
    {
    cout<<"\nEnter the distance in meters-centimeters:";
    cin>>m;
    }
    void display(dm b)
    {
    cout<<"\nTotal distance in meters-centimeters:"<>f;
    }
    void display(db d)
    {
    cout<<"\nTotal distance in feet-inches:"<meters-centimeters"<<"\n2>feet-inches";
    cin>>n;
    switch (n)
    {
    case 1: b=add(a,c);
    b.display(b);
    case 2: d=sum(a,c);
    d.display(d);
    }
    cout<<"\nDo you want to continue?";
    cout<<"\nPress 1 if yes\n";
    cin>>y;
    }while(y==1);
    getch();
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Moved to C++ Programming.

    You should fix your posted code so that it is compilable. You should also post it with proper indentation. Oh, and you should describe the problem that you are facing.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    930
    It seems to me you just copied some random code, you don't even have an int main().

    You should learn at least the basis of the language before trying to compile anything.

    cout<<"\nEnter the distance in meters-centimeters:";
    Its either meter or centimeter, not both.
    Using Windows 10 with Code Blocks and MingW.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Program Conversion Help
    By magda3227 in forum C Programming
    Replies: 6
    Last Post: 06-13-2008, 01:24 PM
  3. Minute to hour/minute conversion program
    By Remius in forum C Programming
    Replies: 7
    Last Post: 12-29-2007, 08:39 AM
  4. program conversion.
    By nesagsar in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2006, 04:04 PM
  5. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM