[C++]My first program ( Calculator )

Results 1 to 8 of 8
  1. #1
    Account Upgraded | Title Enabled! TheUltimate is offline
    MemberRank
    Apr 2007 Join Date
    BelgiumLocation
    868Posts

    [C++]My first program ( Calculator )

    I just begon C++ and this is my first program thx to guides of ragezone

    Code:
    #include <iostream.h> 
    #include <windows.h> 
    #include <stdio.h> 
    #include <conio.h> 
    #include <iomanip.h> 
    #include <string.h> 
    int main() 
    { 
    int keuze; 
    long num1; 
    long num2; 
    char count; 
    long som; 
    char yesno; 
    menu: 
    system("cls"); 
     
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); 
    cout << "1. Calculator" << endl; 
    cout << "2. Exit" << endl; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN); 
    cout << "Make your choice: " << endl; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED); 
    cout << "--> "; 
    cin >> keuze; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); 
    system("cls"); 
    if(keuze==1){ goto calculator; } 
    if(keuze==2){ goto exit; } 
    else { 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED);      
    cout << "Wrong input!" << endl; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); 
    cerr << "Press any key to continue"; 
    getchar(); 
    goto menu; } 
    calculator: //########### REKENMACHINE!! 
    system("cls"); 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); 
        cout << "Number1: "; 
        cin >> num1; 
        cout << "Number2: "; 
        cin >> num2; 
        cout << "calculation (*, +, - of /):"; 
        cin >> count; 
    system("cls"); 
    if(count=='*'){ som = num1 * num2; } 
    if(count=='-'){ som = num1 - num2; } 
    if(count=='/'){ som = num1 / num2; }; 
    if(count=='+'){ som = num1 + num2; } 
        cout << "outcome:" << endl; 
        cout << num1 << " " << count << " " << num2 << " = " << som << endl << endl; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_GREEN); 
    cout << "You want to make another calculation?" << endl << "[Y/N]: "; 
    cin >> yesno; 
    if(yesno=='y'){ goto calculator; } 
    if(yesno=='n'){ goto menu; } 
    else { goto confirm_calc; } 
    confirm_calc: 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED); 
    cout << endl << endl << endl << "Wrong input!" << endl; 
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_GREEN); 
    cout << "Do you want to make another calculation?" << endl << "[Y/N]: "; 
    cin >> yesno; 
    if(yesno=='y'){ goto calculator; } 
    if(yesno=='n'){ goto menu; } 
    else { goto confirm_calc; } //########### REKENMACHINE!! 
    exit: 
    return 0; 
    }

    CalculatorDutch.rar

    CalculatorEng.rar

    With me they work so I hope it was a nice first try :p

    All comments are welcome


  2. #2
    Account Upgraded | Title Enabled! passie is offline
    MemberRank
    Jan 2005 Join Date
    The NetherlandsLocation
    710Posts

    Re: [C++]My first program ( Calculator )

    lol i did see this somewere on google looks complete the same only you changed some collors

  3. #3
    Account Upgraded | Title Enabled! TheUltimate is offline
    MemberRank
    Apr 2007 Join Date
    BelgiumLocation
    868Posts

    Re: [C++]My first program ( Calculator )

    I followed a guide on a website but it was just info not something like this one

  4. #4
    Account Upgraded | Title Enabled! passie is offline
    MemberRank
    Jan 2005 Join Date
    The NetherlandsLocation
    710Posts

    Re: [C++]My first program ( Calculator )

    sec ill google and post it you will see

  5. #5
    Account Upgraded | Title Enabled! TheUltimate is offline
    MemberRank
    Apr 2007 Join Date
    BelgiumLocation
    868Posts

    Re: [C++]My first program ( Calculator )

    K then please post me a link , but i realy used a guide for it
    i didnt use full code

  6. #6
    pork pork Parker is offline
    MemberRank
    Dec 2007 Join Date
    new holland.Location
    5,873Posts

    Re: [C++]My first program ( Calculator )

    PSC?
    Seem's alot like it.

  7. #7
    Account Upgraded | Title Enabled! Intelext is offline
    MemberRank
    Mar 2007 Join Date
    EuropeLocation
    1,228Posts

    Re: [C++]My first program ( Calculator )

    Quote Originally Posted by passie View Post
    lol i did see this somewere on google looks complete the same only you changed some collors
    Owh my god, someone copied DOS STYLE CALCULATOR, jail him!!
    Chill man, it's not worth it anyway.

    Good work on first project, but it has some bad aspects like when I can enter letters there, so bsically i can make something like this: 3 Z 4 = ??

    Or something like this:

    3 ZWSAGHGDA 4 = BUG :)

    Practise more, make application with GUI, good luck. :clap:

  8. #8
    Account Upgraded | Title Enabled! New User is offline
    MemberRank
    Dec 2007 Join Date
    CanadaLocation
    1,001Posts

    Re: [C++]My first program ( Calculator )

    It's nice but I guess it'll be better if you actually add in different buttons such as, "EVAPORATE" for erasing the numbers, or "ELIMINATE" for closing the program.

    That's just an IDEA.

    Anyways, nice Calculator, works fine / pretty good.



Advertisement