Thread: Please test my calculator prog

  1. #61
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    All you have to do is use a float (or double) for the variable.

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    using namespace std;
    
    float decimal_num;  //or you can use double
    
    int main()
    {
    
          cout << "Enter any decimal number" << endl;
          cin >> decimal_num;
          cout << "You decimal number is " << decimal_num << endl;
          
    
          system("PAUSE");
          return 0;
    }

  2. #62
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    TechWins> That's what all of them are, and I still can't get it to work. The output answer works in decimal, just not the input *I rewrote my code to test what you said*.

    RoD> Already did that, this is what I did:
    1] Changed <iostream> to <iostream.h>

    2] Took out 'using namespace std;

  3. #63
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Can you post the code where the problem is at?

    Btw, using namespace std and iostream is fine so don't go back to iostream.h

  4. #64
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Oh yeah, are you using casting the float to an int before you display the code? If you are then of course you're not going to see the decimal and the numbers after the decimal.

  5. #65
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Originally posted by TechWins
    Can you post the code where the problem is at?

    Btw, using namespace std and iostream is fine so don't go back to iostream.h
    Can't. I deleted it. But, I do remember the problem was after I put the ShowMenu function to show the menu, after that, every cout, cin, and cerr had an abiligious symbol error.

  6. #66
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    But, I do remember the problem was after I put the ShowMenu function to show the menu, after that, every cout, cin, and cerr had an abiligious symbol error.
    No idea about that, sorry.

  7. #67
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Originally posted by Quantrizi
    Good point...heh. But, would you still have to include conio.o *gotoxy is in the conio header(s)*
    Nope, gotoxy isnt in conio.h, I did the function gotoxy():
    functions.h
    Code:
    #include <iostream>
    #include <conio.h>
    #include <stdlib.h>
    #include <windows.h>
    
    using namespace std;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
    
    // Declerations
    void gotoxy(int,int);
    void SetColor(short);
    
    // Definitions
    void SetColor(short Color)
    { 
      SetConsoleTextAttribute(hConsole, Color);
    }
    
    void gotoxy(int x, int y)
    {
      COORD CursorPosition;
      CursorPosition.X = x;
      CursorPosition.Y = y;
      SetConsoleCursorPosition(hConsole, CursorPosition);
    }
    what does signature stand for?

  8. #68
    Registered User
    Join Date
    Sep 2002
    Posts
    22
    post the .exe lol not the zip i cant open .zip at school =\
    Laugh

  9. #69
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    Originally posted by Ruski
    Nope, gotoxy isnt in conio.h, I did the function gotoxy():
    functions.h
    Code:
    #include <iostream>
    #include <conio.h>
    #include <stdlib.h>
    #include <windows.h>
    
    using namespace std;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
    
    // Declerations
    void gotoxy(int,int);
    void SetColor(short);
    
    // Definitions
    void SetColor(short Color)
    { 
      SetConsoleTextAttribute(hConsole, Color);
    }
    
    void gotoxy(int x, int y)
    {
      COORD CursorPosition;
      CursorPosition.X = x;
      CursorPosition.Y = y;
      SetConsoleCursorPosition(hConsole, CursorPosition);
    }
    just to let you know this is only for windows, ppl who use other stuff wont be able to view your calc, kinda ironic that you dont like the ms calc and make your own which runs only under ms opeating systems hehe
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  10. #70
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Red Baron> True, but if someone would like to port it to Linux or whatever, be my guest.

    I don't like the M$ calc. because of the minimal stuff it has. By that I mean the fact it is hard to read all of the trig. functions, it can't solve proportions, graph a line, solve a slope-intercept problem, and etc. I am currently gonna try my hardest to do this and more. Heavy production will occur after Christmas, and after my robotics regionals and such are done with.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer Emulation
    By Elysia in forum C++ Programming
    Replies: 31
    Last Post: 03-18-2008, 01:03 PM
  2. undefined reference
    By 3saul in forum Linux Programming
    Replies: 12
    Last Post: 08-23-2006, 05:28 PM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. MSVC Template Constructor/Assignment Errors
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:57 PM
  5. Why is my program freezing?
    By ShadowMetis in forum Windows Programming
    Replies: 8
    Last Post: 08-20-2004, 03:20 PM