Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted

    Question [Help]My Learning Status

    Okay guys,
    I have this code I have been messing around with a little bit that I wrote on my own, as a way to take what I am currently learning from the book I am reading, and put it into something more than just retyping source codes that're in the book. I want to try many different methods that'll produce practically the same outcome for this simple program.

    The whole point here with this program is for me to enter the amount of pages I have read, and have it automatically calculate the percentages for me to update my sig with, of my C++ Learning Status.

    What I am having a problem with here is I have it set up where it outputs the percentage I am on the CURRENT book I am reading, and the total percentage outta the 2(soon will be MORE) books I have on C++. The problem is that when I am done with the first book(1225 pages long) and I start on my other book, that means I will have read for example 1230 pages(5 pages of the next book and ALL 1225 of the first), it doesn't make the FIRST book stop at 100% it makes the percentage of the first book show as 100.41%. I need some advice on how to get this to stop at 100% but for it to STILL count up the total percentage.

    Here's my code::
    [php]
    // Credits:
    // D-Vid aka Illusionz -- DBag4Life on MPGH
    // flashlight95 -- For the idea of using the if
    // crash
    #include <iostream>

    int main()
    {
    using namespace std;
    float CppPrimer = 1225;
    float total = 2501;
    int pages;

    cout << "Enter the total amount of pages that you've read so far: \n\n";
    cin >> pages;
    cout << endl;
    if (pages>total)
    {
    cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
    system("PAUSE");
    cout << endl;
    }
    else if (pages<total)
    {
    cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
    cout << "Percentage TOTAL outta all the books: " << pages / total * 100 << "%" << endl;
    system("PAUSE");
    cout << endl;
    }
    else
    {
    cout << "You're DONE learning from those books!" << endl;
    system("PAUSE");
    cout << endl;
    }
    return 0;

    }
    [/php]

    I would like to hear some constructive criticism, but I don't want any flaming. I AM new at C++, and I am trying to learn different styles of coding.

  2. #2
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    [php]cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl; [/php]

    1230/1225 = 1.004
    1.004 * 100 = 100.4.

    I pointed out why it's doing it, though i won't give any code.

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  3. #3
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    Quote Originally Posted by Kallisti View Post
    [php]cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl; [/php]

    1230/1225 = 1.004
    1.004 * 100 = 100.4.

    I pointed out why it's doing it, though i won't give any code.
    Well, I already figured that one out, smart one. /
    I am looking for a way to figure out how to MAKE that NOT happen. lolz.

  4. #4
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Well, it's saying percentage from C++ primer, why would you want to show added percentage from both?

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  5. #5
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    I think I made it do what I wanna do, but it's not 100% fixed yet.
    It keeps wanting to terminate itself when I put 1225 as the amount of pages... :-|

    [php]
    // Credits:
    // D-Vid aka Illusionz -- DBag4Life on MPGH
    // flashlight95 -- For the idea of using the if
    // crash
    #include <iostream>

    int main()
    {
    using namespace std;
    float CppPrimer = 1225;
    float VCpp = 1276;
    float total = 2501;
    int pages;

    cout << "Enter the total amount of pages that you've read so far: \n\n";
    cin >> pages;
    cout << endl;
    if (pages>total)
    {
    cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
    system("PAUSE");
    cout << endl;
    }
    else if (pages<total)
    {
    if (pages>CppPrimer)
    {
    cout << "Percentage outta the C++ Primer Plus: 5th Edition: 100%" << endl;
    cout << "Percentage TOTAL outta all the books: " << (pages/total)*100 << "%" << endl;
    system("PAUSE");
    cout << endl;
    }
    else if (pages<CppPrimer)
    {
    cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << (pages / CppPrimer) * 100 << "%" << endl;
    //cout << "Percentage outta the Visual C++ 2010: " << (pages / VCpp) * 100 << "%"<< endl;
    cout << "Percentage TOTAL outta all the books: " << (pages / total) * 100 << "%" << endl;
    system("PAUSE");
    cout << endl;
    }

    }
    else
    {
    cout << "You're DONE learning from those books!" << endl;
    system("PAUSE");
    cout << endl;
    }
    return 0;

    }
    [/php]

  6. #6
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love

    [php]if(pages==CppPrimer)
    {
    cout << "Done with CPP Primer\n";
    cout << "0% with others\n";
    //rest?
    }[/php]


    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  7. #7
    Gab's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,716
    Reputation
    1755
    Thanks
    1,543
    What does that line do?

    Code:
     cout << endl;

  8. #8
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    https://mpgh.net MPGHCash: $442,596,199
    Posts
    5,645
    Reputation
    26
    Thanks
    896
    My Mood
    Happy
    Quote Originally Posted by xXModz View Post
    What does that line do?

    Code:
     cout << endl;
    it skips a line. endl = \n

  9. #9
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    Quote Originally Posted by xXModz View Post
    What does that line do?

    Code:
     cout << endl;
    lolz. Are you for real??
    You haven't learned that yet?

    cout is the (see-out) You output text with it.
    endl is (end line) You skip that line and start the text on the NEXT one.

  10. #10

  11. The Following User Says Thank You to Void For This Useful Post:

    Melodia (09-26-2010)

  12. #11
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Quote Originally Posted by Void View Post
    I always use \n

    |:
    Me too

    easier is easier.

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  13. #12
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    Quote Originally Posted by Void View Post
    I always use \n

    |:
    Quote Originally Posted by Kallisti View Post


    Me too

    easier is easier.
    Yeah, \n and endl; have the SAME outcome, but IDK, I have been using endl; since I started, so I guess for me it's easier. :-|

    But whenever I learn to write BIG complex programs, most likely i'll use \n to make it less typing. lolz.

  14. #13
    Gab's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,716
    Reputation
    1755
    Thanks
    1,543
    Quote Originally Posted by DBag4Life69 View Post


    lolz. Are you for real??
    You haven't learned that yet?

    cout is the (see-out) You output text with it.
    endl is (end line) You skip that line and start the text on the NEXT one.
    Yes I know what's a cout and an endl.... But please use \n... MORE PROFESSIONAL

  15. #14
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Quote Originally Posted by xXModz View Post
    Yes I know what's a cout and an endl.... But please use \n... MORE PROFESSIONAL
    I'm sorry, this post fails.

    Who says it's more professional? You don't even know much C++

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  16. #15
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Code:
    if (yourpercentagevariablehere > 100)
        yourpercentagevariablehere = 100;
    wow very hard.

Page 1 of 2 12 LastLast

Similar Threads

  1. [help] C++ learn...
    By Doom_RadexPl in forum C++/C Programming
    Replies: 1
    Last Post: 01-25-2011, 12:32 PM
  2. HELP / REQUEST : Learning to code
    By TurTLeZ in forum C++/C Programming
    Replies: 6
    Last Post: 09-20-2010, 10:39 PM
  3. [Help] Rezinjector file status not found
    By shurusha in forum Combat Arms Mod Discussion
    Replies: 9
    Last Post: 07-09-2010, 07:57 AM
  4. Help Me Learn How to Make Hacks!
    By reviver555 in forum Alliance of Valiant Arms (AVA) Hacks & Cheats
    Replies: 4
    Last Post: 10-30-2009, 11:43 PM
  5. Please Help Me Learn How to Hack
    By revelationx25 in forum Combat Arms Help
    Replies: 5
    Last Post: 09-05-2009, 03:56 PM