[Attempt] Properly made C++ Calculator menu

User Tag List

Results 1 to 14 of 14
  1. #1
    Xel's Avatar ★ Elder ★
    Authenticator enabled
    Reputation
    1179
    Join Date
    Jul 2008
    Posts
    2,906
    Thanks G/R
    94/51
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Attempt] Properly made C++ Calculator

    First of all
    YES, I have the motivation and will to learn these things,
    NO not just for hacking.

    YES, I have been learning C++ for a few weeks now.
    NO, I'm not sure if this calculator is even near to proper one.

    So please help me to learn more, tell me what's wrong, not
    recommended or just pure failure. I can take it.


    Code:
    #include "iostream.h"
    #include "windows.h"
     
    using namespace std;
     
    int main()
    {
        SetConsoleTitle( "Simple Calculator" );
        double num1,num2,result;
        char op;
     
        cout<<"Calculator\n\n";
        cout <<"+ = addition\n- = subtraction\n/ = division\n* = multiplication\n\n";
        while(cin>>num1>>op>>num2)
        {
            switch(op)
            {
                    case '+': result = num1 + num2;
                    break;
                    case '-': result = num1 - num2;
                    break;
                    case '*': result = num1 * num2;
                    break;
                    case '/': 
                    if (num2!=0)
                        result = num1 / num2;
                    else
                        cout << "Error #1, Dividing with zero not defined\n\n";
                    break;
                    default: cout<<"Error #2, Invalid operator: '"<<op<<"'\n\n";
                    continue;
            }
            if (num2!=0)
            cout<<"Answer: "<<result<<"\n\n";
        }
     
        return 0;
    }
    Example:

    Code:
    Calculator
     
    + = addition
    - = subtraction
    / = division
    * = multiplication
     
    2+5
    Answer: 7
     
    2*298
    Answer: 596
     
    1337/0
    Error #1, Dividing with Zero not defined!
     
    524%5
    Error #2, Invalid operator: '%'!
    Last edited by Xel; 12-14-2009 at 08:50 AM. Reason: As I thought, I'm not ready to ask for memory stuff yet.

    [Attempt] Properly made C++ Calculator
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd say what I'm thinking, but it would probably result in a ban.

    So, I'll just say this...

    I don't know where you're "learning" C++ from, but wherever it is, either they're terrible teachers or you're not paying enough attention.

  3. #3
    Xel's Avatar ★ Elder ★
    Authenticator enabled
    Reputation
    1179
    Join Date
    Jul 2008
    Posts
    2,906
    Thanks G/R
    94/51
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Cypher:

    I would be more than thankful if you could point out where I went wrong.
    If you do not have enough time (very possible if it's all wrong), could just
    point the worst mistakes so that I can learn from them?

    You can add me on MSN and honestly say what you think: Xel(a)Gmx.com.

    Anyways.. Would a "if that and if this" calculator be better because I was able
    to do that some weeks ago. The point was not to make a perfect calculator meaning
    that it does not have possibilities to calculate more than 2 numbers at time.

    I learned this "switch, while, case" stuff a short time ago and I thought that maybe
    they could make the calculator a bit more proper than just a one based on dozens
    of if's.

    I am studying C++ from Finnish websites, whose quality might not be so great.
    I don't own a good coding language skills (in English) and I have mainly come
    across some very cryptic sites while trying to learn C++ from English websites.
    Last edited by Xel; 12-14-2009 at 08:49 AM.

  4. #4
    BonutDot's Avatar Contributor
    Reputation
    235
    Join Date
    Aug 2006
    Posts
    418
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you should switch statements in there at all. Switch is usually a replacement for a whole bunch of if statements. If you're going to be feeding your calculator program statements that would evaluate normally anyway (like 2+2), there's probably a simpler way to do it.

  5. #5
    hexonflux's Avatar Member
    Reputation
    10
    Join Date
    Mar 2007
    Posts
    40
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cypher, it doesn't sound like Xel is looking to make an operating
    system any time soon or hack the pentagon.... So maybe some
    more encouraging words are in order?

    My "constructive criticism" to -You- Cypher is, if you're going
    to release an application after you just flamed countless people
    for mistakes or errors in their syntax. Don't compile under .NET
    and expect the rest of us Actual C++ programmers to rejoice in
    the fact you're either really lazy or just a half-ass coder, period.
    It's really just a slap in the face.


    And back on topic:

    The kid's learning C++ so give him some slack. At least he's not
    handing out shitty information like a few others that have posted
    tutorials or how-to's for C++. It's a small application that does a
    few simple calculations. For what he knows and what it is, it's a
    good step in the right direction.

    GJ Xel, keep up the good work.


    - Hex


  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by hexonflux View Post
    [SNIPPED]
    My "constructive criticism" to -You- Cypher is, if you're going
    to release an application after you just flamed countless people
    for mistakes or errors in their syntax. Don't compile under .NET
    and expect the rest of us Actual C++ programmers to rejoice in
    the fact you're either really lazy or just a half-ass coder, period.
    It's really just a slap in the face.
    [SNIPPED]
    What the **** are you talking about? Can you please rephrase that paragraph in English... (Or can someone here please do a Dipshit->English translation for me? Thanks.)

  7. #7
    hexonflux's Avatar Member
    Reputation
    10
    Join Date
    Mar 2007
    Posts
    40
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LuaNinja

    * You will need the .NET 4.0 Beta 2 framework.
    REALLY? REALLY? What happened to programming without
    the help from a slow-ass runtime environment made by
    Microphail?


    So in more plain English, I'm criticizing the fact that you depend on
    the .NET framework. Every programmer that I've ever met that's
    not just some box-jockie and actually made more than 150k a year
    for what they know has laughed at the idiots who rely on the
    .NET framework. You have people from Verio, EDS, and Sun
    Microsystems laughing at guys like you who think they know
    everything when you really don't know... jack shit. You criticize
    and flaunt your "programming skills" but you're just some little
    punk with a few years of experience as opposed to the newbies
    you pick on.

    You should come meet a few friends of mine, Cypher. I'd like you
    to talk to them like you talk to the kids on this forum and see if
    you get the same gratification. I'm sure we'll all have a bundle of
    laughs with you around.... don't forget your helmet. Wouldn't want
    you to feel too retarded.


    - Hex




  8. #8
    Nikentic's Avatar Elite User
    Reputation
    453
    Join Date
    Oct 2007
    Posts
    1,556
    Thanks G/R
    10/4
    Trade Feedback
    6 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would an helmet help against criticism?

  9. #9
    hexonflux's Avatar Member
    Reputation
    10
    Join Date
    Mar 2007
    Posts
    40
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o_O I really hope I don't have to explain that one.

  10. #10
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by hexonflux View Post

    LuaNinja



    REALLY? REALLY? What happened to programming without
    the help from a slow-ass runtime environment made by
    Microphail?


    So in more plain English, I'm criticizing the fact that you depend on
    the .NET framework. Every programmer that I've ever met that's
    not just some box-jockie and actually made more than 150k a year
    for what they know has laughed at the idiots who rely on the
    .NET framework. You have people from Verio, EDS, and Sun
    Microsystems laughing at guys like you who think they know
    everything when you really don't know... jack shit. You criticize
    and flaunt your "programming skills" but you're just some little
    punk with a few years of experience as opposed to the newbies
    you pick on.

    You should come meet a few friends of mine, Cypher. I'd like you
    to talk to them like you talk to the kids on this forum and see if
    you get the same gratification. I'm sure we'll all have a bundle of
    laughs with you around.... don't forget your helmet. Wouldn't want
    you to feel too retarded.


    - Hex



    Lol @ you.

    The loader and hack are written in C++, the GUI is written in C#. But it's irrelevant.

    That post alone makes it obvious you don't have a clue what you're talking about. Stop living in the 90s. When you're ready to join us in the 20th century, let me know, and I'll be happy to help catch you up.

    The fact that you don't know anyone who makes over 150k a year and uses .NET simply means YOU DON'T KNOW ANYONE.

    I've yet to see any of your posts actually give evidence or reasons to back up your claim other than purely subjective hearsay like "it's slow" and "it's big". You're so brilliant (though I have yet to see any evidence of that), and your friends are so smart (again, yet to see any evidence of that either), so how about you show me why .NET sucks so much?

    Rofl. Have fun living in fairly land.
    Last edited by Cypher; 12-19-2009 at 11:18 PM.

  11. #11
    hexonflux's Avatar Member
    Reputation
    10
    Join Date
    Mar 2007
    Posts
    40
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tsk. Tsk.

    Do not use high level languages, libraries, frameworks, virtual machines or runtimes in core operating system processes

    For one .NET Framework is not for core operations. "Stop living in the
    90s".

    The 90s? When .NET Framework becomes a vital component to the
    development of Linux/Unix based operating systems then I'll give it a
    go. Until then I think I'll stick with C++.


    So .NET Framework has thousands of functions and libraries to work
    with. And you even have added security features. It's not a pain in the
    ass to install anymore and you don't have to worry about compatibility
    with other up-to-date windows operating systems 70% of the time.
    But when you go from 9 years of C++ to some moron flaunting his nuts,
    it's kinda irritating.

    I guess if you want to go through a second runtime, and relish
    in the same phailpool that Microsoft has been swimming in since it's
    very existence then that's you. Maybe using the new beefed version
    of C++ that Microsoft has thrown together and ****ed up beyond
    recognition is more fun.


    Think of it this way. Lets say you're going to work for a federal
    bank, much like my father does. You're the head of administration
    and you're having to keep tabs on everything that's going on.
    Maybe there's an issue. You need to log into one of the
    upper-security data centers on level B. Are you going to bust out
    the Microsoft Visual C++ Express edition and go to work? **** no
    you're going to login via SSH and use at least 4 different
    programming languages including C++ and Perl for web based apps.

    You need speed. .NET Framework is a second runtime which handles
    all of the applications resources completely different than the 'naked'
    operating system. The Microsoft website says that everywhere.

    You need versatility. Perl and C work amazing together. The fact that
    Perl is so fast and you can make almost any application using it. And
    C is old, yea, but it does the job just fine. C++ being a beefed up version
    of C ( the ++ in C++ is from the increment operator ) is just icing on the
    cake. Do you know why I laugh when I see .NET and security in the
    same sentence? Because you didn't write the damn function you instead
    frowned on what's considered the depreciated API library and used the
    .NET Framework.


    You wanted a reason why .NET Framework sucks, well there ya go.
    When speed, power, reliability, assurance, and overall compatibility
    is needed; .NET Framework is no where to be found.


    Cypher you're just some punkass kid. You're no better than the 35
    year old men who ran the MyG0t clan in Counter-Strike. Using cheap
    ass tricks to lure people to test their applications. Not knowing even
    half of what they're coding. Just copying and pasting from a manual
    or a tutorial because it sounded right at the time. Analyzing applications
    with a disassembler, 'thinking' they know what they're talking about.

    Hell maybe you knew some of them. I don't know. But what I do know
    is if you even remotely think you know anything. Then you'll always
    know nothing. Period.



    - Hex





  12. #12
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hahahaha, oh my god this shit is just too funny.

    Awesome work posting a wall of text yet somehow STILL managing to not do what I've asked.

    When you're ready to stop spewing hearsay/lies/misconceptions/etc and start presenting some actual evidence so we can have a civil dicussion, let me know. Otherwise I'm gonna go do something more productive (like talking to my cat, or a brick wall. at least then I don't have to listen to them spewing garbage like you).

    P.S. The fact that you think the support article you linked is relevant shows how little you know. We're not talking about writing parts of the core OS here, we're talking about 'normal' applications (you were the one who brought up my Lua hack, and it certainly does not come under the same category as Winlogon or LSASS).

  13. #13
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Holy hell; I think 1/2 my brain just died.

    To respond to your KB article; did you even read it?

    We recommend that you only use C languages and Win32 APIs for any add-in components that are loaded by core operating system processes. Two examples of core operating system processes are Winlogon.exe and Lsass.exe.

    The behavior of any high-level language, framework, or runtime in the components that are loaded by core operating system processes is undefined. For example, the Microsoft .NET Framework and the common language runtime were not designed to run in the context of core operating system processes.
    They tell you not to use it; since they DON'T KNOW WHAT MAY HAPPEN. Very different to 'don't use it because it's slow/sucks/etc/etc'.

    At any rate; any of your 'intelligent friends' or whatever you want to call your imaginary friends now; would know that coding something very simple [such as Cypher's loader GUI] makes no difference which language it's in. Coding it in C# just avoided a few minutes of extra dev time by having the GUI designer do most of the heavy lifting.

    Also; to put your dumbass argument about speed aside; the .NET runtime [in most cases] runs as fast as native C++ applications. Why is that? Because in the end; THEY ARE NATIVE APPLICATIONS. Granted; certain 'low level' tasks [such as dropping down to ASM level for the utmost in optimizations] aren't available in .NET. But then again; if you need to get that low level; you don't use .NET anyway.

    If you want to throw arguments around like a retarded ass monkey with a pipe up his ass; at least do some research. .NET was made originally for Windows programming. Not Mac/Linux/anyotherflavoroflinuxyoufapto. The fact Mono came to be just supports how good .NET is, and how well received it was.

    Also; Cypher actively contributes to multiple open source projects [ReactOS, Wine, Chrome, FireFox], what do you do? Talk to your non-150k a year friends that don't work at Sun?

    Show proof you even know what the hell you're talking about [and no; Googling 'why not to use .NET' doesn't count] and maybe I'll have an intelligible conversation. Until then; I leave you with 3 words. DERP DERP DERP.
    Last edited by Apoc; 12-20-2009 at 12:59 AM.

  14. #14
    Xel's Avatar ★ Elder ★
    Authenticator enabled
    Reputation
    1179
    Join Date
    Jul 2008
    Posts
    2,906
    Thanks G/R
    94/51
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WoW that helped me alot, thanks :-/.

Similar Threads

  1. [Database] Custom made Weapons don't work properly
    By Wheeze201 in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 07-01-2010, 01:28 AM
  2. The PropEr Way To Release a Custom Made Anything
    By Mr. Herbert in forum World of Warcraft Emulator Servers
    Replies: 10
    Last Post: 02-20-2008, 06:41 PM
  3. NE Male | Druid | Requesting Modelchange, attempts have been made.
    By Ensey in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 06-30-2007, 08:09 PM
  4. How +Spell Damage Is Calculated For Mages
    By impulse102 in forum World of Warcraft Guides
    Replies: 7
    Last Post: 08-06-2006, 06:08 AM
All times are GMT -5. The time now is 05:59 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search