Thread: C++ Assignment Help Please!

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Perhaps you really should fail then.

    Harsh maybe, but there's an awful lot of failure going around at the moment. Sooner or later, you're going to have to deal with some kind of failure yourself. Mummy's precious little rug-rat may have gotten everything handed on a plate, but here in the real world, your bleating ain't worth a damn.

    Just take the hit, learn from it, and be content that programming isn't for you.

    > I hella don't pay attention in this class...
    OK, that nails it - you don't deserve to pass.
    Don't even pretend you can make it as a programmer, just go to the admin office and drop the course now. Don't even bother trying to take the mid-term. Even if you passed by some fluke, the only person being fooled into thinking you can do this will be you.

    This is a simple test to see who goes on, and who doesn't.
    The problems which will come are going to get a lot harder in a hurry.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #17
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Quote Originally Posted by Salem View Post
    Perhaps you really should fail then.

    Harsh maybe, but there's an awful lot of failure going around at the moment. Sooner or later, you're going to have to deal with some kind of failure yourself. Mummy's precious little rug-rat may have gotten everything handed on a plate, but here in the real world, your bleating ain't worth a damn.

    Just take the hit, learn from it, and be content that programming isn't for you.

    > I hella don't pay attention in this class...
    OK, that nails it - you don't deserve to pass.
    Don't even pretend you can make it as a programmer, just go to the admin office and drop the course now. Don't even bother trying to take the mid-term. Even if you passed by some fluke, the only person being fooled into thinking you can do this will be you.

    This is a simple test to see who goes on, and who doesn't.
    The problems which will come are going to get a lot harder in a hurry.
    A lot of truth to this. I see kids pass cs 135 and sometimes 202 the starting c++ courses in college, but as soon as they hit the upper level classes they totally dive bomb. And then if you happen to somehow cheat your way through the system you end up at a job where all your co-workers despise you due to the fact you are dangerous to the product.

    Moral is you should pay attention and work hard for the education you are paying for ><

  3. #18
    Registered User
    Join Date
    Oct 2008
    Posts
    11
    I'm not trying to pretend I've learned anything, I'm just trying to pass the class. It doesn't matter to me at all because this has absolutely nothing to do with my major and I won't touch another programming class after it. It's simply gen-ed and I have no interest or desire in programming beyond this. It's not that I haven't tried in the class. More than anything else, the assignment is extremely unclear to me and I don't know how to use loops or how to make the program capable of determining whether or not DtoB or BtoD should be used or if I should just have it asking for both with two separate prompts.

    BtoD and DtoB in the same program isn't extremely difficult to me. But if I have to have them answered in one prompt and make the program capable of determining which was entered, that's the part I cannot begin.

  4. #19
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Registered User


    Join Date: Oct 2008
    Posts: 9 I'm not trying to pretend I've learned anything, I'm just trying to pass the class. It doesn't matter to me at all because this has absolutely nothing to do with my major and I won't touch another programming class after it. It's simply gen-ed and I have no interest or desire in programming beyond this. It's not that I haven't tried in the class. More than anything else, the assignment is extremely unclear to me and I don't know how to use loops or how to make the program capable of determining whether or not DtoB or BtoD should be used or if I should just have it asking for both with two separate prompts.

    BtoD and DtoB in the same program isn't extremely difficult to me. But if I have to have them answered in one prompt and make the program capable of determining which was entered, that's the part I cannot begin.
    ..which still makes me wonder how is this our problem? Also since you did not pay attention in class which is a conscious decision that you made at the time I believe you deserve to fail the class be it a gen-ed or not.

    In short: A lack of planning and preparation on your part does not constitute an emergency on ours.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There would not be a programming class in your course if the knowledge was not necessary in a way.
    In short: if you fail the programming class, you fail the entire course. The end.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Registered User
    Join Date
    Oct 2008
    Posts
    11
    Here's what I have come up with for the code on converting a decimal number to binary using a string:

    Code:
    // This program will test the function BtoD
    //   int BtoD (string Binary);  is the prototype
    //  will convert any byte (8bits) from binary to decimal
    #include <iostream>
    #include <string>
    using namespace std;
    
    
    string dec2bin(int Decimal);
    
    
    string dec2bin(int Decimal)
    {
    int steps[] = {128, 64, 32, 16, 8, 4, 2, 1};
    string binary;
    
    if(Decimal > 0)
    {
    int stepLen = sizeof(steps) / sizeof(int);
    for(int x = 0; x < stepLen; x++)
    {
    if(Decimal >= steps[x])
    {
    Decimal -= steps[x];
    binary += "1";
    }
    else
    binary += "0";
    }
    }
    else
    binary = "0";
    
    return binary;
    
    }
    
    
    
    // The driver program follows
    
    
    int main()
    {
    cout << "Enter an integer no larger than 255: ";
    int Decimal;
    cin >> Decimal;
    if (Decimal > 255)
    {
    cout << "Please follow instructions" << endl;
    }
    else
    {
    cout << "Binary: " << dec2bin(Decimal) << endl;
    }
    system("PAUSE");
    return 0;
    }
    After this, how would I go about making the program capable of distinguishing between a binary or decimal input and then converting it?

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    How would you do it in real life?
    And you need to learn how to indent.
    You can't expect us to read that unreadable code mess.

    It's good to see that you're making an attempt at least.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #23
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Nah, he hasn't "come up" with anything; he got it from here.

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Of course "he" has.
    I take back what I said earlier.
    This guy deserves to fail.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    Registered User
    Join Date
    Oct 2008
    Posts
    11
    What a bunch of Nazis. Seriously, since when do people really do their own work in school? I don't remember that ever being the case.

  11. #26
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I think we are done here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Help with a pretty big C++ assignment
    By wakestudent988 in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2006, 09:46 PM
  5. Replies: 1
    Last Post: 10-27-2006, 01:21 PM