Can you people please tell me what you think about this "game"? It's a basic calculator done in Console. It was done in MSVC++ 6.0 Intro. Version. thanks.
P.S.: If alot of people like it (or atleast a majority), I'll release the source.
Printable View
Can you people please tell me what you think about this "game"? It's a basic calculator done in Console. It was done in MSVC++ 6.0 Intro. Version. thanks.
P.S.: If alot of people like it (or atleast a majority), I'll release the source.
good job man :)
have a cout <<"\n"; after your options so the user choice isn't right under the options list
Thnx. Ok, thnx 4 the advice.Quote:
Originally posted by Ride -or- Die
good job man :)
have a cout <<"\n"; after your options so the user choice isn't right under the options list
The reason i say this is to help make it flow better in terms of reading. I personaly would go one step further and have a prompt.
instead of
cout<<"\n";
u could use:
cout<<"\nEnter Choice: ";
they would see
Enter Choice:
Ok, here's the update. Just fixed what you said, and the version. I also added a title to it. Plus, the source is with it. Hopefully it'll help people out, or you people can help me out on how to optimize or whatnot (I'll give credit). Thanks.
my quick suggestion implemented: (i'll look it over carefully tommorow and see what i notice : ) )
Code:void begin()
{
system("cls");
header();
cout << "Welcome to Calculator v"<<calculator.version;
cout << "."<<calculator.extension <<" "<<calculator.nversion<<"!\n";
cout << "\nPlease select an option:\n";
cout << "1] Multiply\n2] Divide\n3] Add\n4] Subtract\n5] Exit|Quit\n";
cout << "\nEnter Choice: "; //added by RoD
cin >> pick.choice;
Nice....now add factorial :)
Thanks RoD, I'll add that.Quote:
Originally posted by kermi3
Nice....now add factorial :)
Kermi3-->-->I'm workin on it! :D *j/p*. But yea, I'm gonna add more in tomorrow, and maybe it'll be better than micro$oft's calc....*come to think about it, counting w/ your fingers is better than using micro$oft's calc*
I made a pretty sweet calc in VB last year that was everything that MS's is with better interface and more options, damned if i can't find my projects cd from VB...
Cool. I hope to do that when I get the hang of Win32 stuff in DirectX.
thats cool man, i gotta admit, i h8 vb and i am developing a love for C++, but GOD do i miss the EASE of VB gui :P
lol aight i'm out for the nite.
tsk tsk ... make sure that when the user selects the divide option, that the second thing entered (the number its dividing the first number by) is not 0! eg,,Code:////////////////////////////////////////////////
//Name: Divide()
//Desc: The division function
///////////////////////////////////////////////
void divide()
{
system("cls");
header();
cout << "Enter the first value you wish to divide: ";
cin >> a; // the first value to be divided
cout << "\nThank you. Enter another value: ";
cin >> b; // the second value to be divided
while(b = 0)
{
cout << "Please enter a number other than 0 please: ";
cin >> b;
}
da = a / b;// ma equals the product of a divided by b
// Give out the product and ask the user a few q's
cout << "\nThe division of the given numbers is: "<<da<<"\n";
cout << "\n\n1] Do more division\n"
"2] Return to main menu\n3] Quit\n\n";
cin >> pick.choice;
// If the user presses '1', then redo the division process
if(pick.choice == 1)
multiply();
// If the user presses '2', then start the game over
else if(pick.choice == 2)
begin();
// If the user presses anything else, then quit and exit the game
else
exit(1);
}
Thanks face_master. I forgot about that. I'm planning on uploading a new version later on today (It'll probably be on my website). Thnx RoD.
This is a new version of the calculator. It now adds the previous stuff that what said here, and now also has a new option to figure the area of a circle. There is a slight bug (warning actually) which states:
main.cpp(34) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
I don't know how to fix this one, so any help would be appreciated. This deals with PI.
truncation from 'const double' to 'float'
I don't know how to fix this one, so any help would be appreciated. This deals with PI.
it means the double is being changed to a float.
The double is "higher" then the float if u will, so its called "demoting".
heres a lil example of pro/demot'n:
promoting -
int example;
int final;
final = double(example); // example is now a double.
Demoting -
double example;
int final;
final = int(example); // Example is now a integer.
Hope this helps! The warning is just lettingu know that this is happening, it won't hurt anything.
Thnx. That helps a lot. Never knew that. So, it'll do nothing to the output or whatnot? Kool. But, is there really anyway to fix it (besides the way you showed me)?
well i don't think it will effect the output because if i member rite both float and double show the decimal point.
Ok, kool. Thnx. Does it work right for anyone that's not on XP?
Yes, it does work on everybody's computer. It's a standard c/c++ practice (it's probably even a standard programming in general practice; I don't know). It is called casting a variable, though.
Ok, thnx. Just wondering, but would me program work for Linux also (or any other OS that isn't Window$)?
I haven't look at your source code, so I wouldn't know. It really all depends on whether you are using Windows specific functions or not.
This recent thread about portability has a very good explanation concering portability by Prelude. She gives an example of a smart way to make your program easily portable.
Ok, thanks. I'll take a look at that.Quote:
Originally posted by TechWins
I haven't look at your source code, so I wouldn't know. It really all depends on whether you are using Windows specific functions or not.
This recent thread about portability has a very good explanation concering portability by Prelude. She gives an example of a smart way to make your program easily portable.
Here's a new version. Added a few new features, fixed a couple of bugs, and some other stuff.
The features I added are:
1. Save/load. It saves the version number, extension, and label for comparision. The load feature has a bug, but I can't fix it (Doesn't display the label).
2. Right triangle. Let's you figure out if the given three values will make a right-triangle.
3. Square root. Figures the squared root of the number.
Note that R.T. means "Right Triangle". I abbriviated it for menu purposes (which has been changed). There could be more options I didn't list here *I can't remember right off hand what the other version had*. I also added a credits list in the readme file.
pretty cool, but what you can do before you keep adding more stuff is like have the program get a string line, for example a person can enter:
2+4+2+3
and it will give u the answer : 11, your program would just have to find the operation signs and the different numbers and basically find the answer, this will probably get very complicated when u have to start doin bedmass stuff and use brackets, etc. but it would be real cool :D
nice job btw
Ok, I ain't feelin all that great today, so can u please run that string line thing past me one more time *:D*. But, sure. I'll give it a try. Would anyone know how to do matrice input *I know how to add them and stuff, just dunno how I would let the user input the values*Quote:
Originally posted by red_baron
pretty cool, but what you can do before you keep adding more stuff is like have the program get a string line, for example a person can enter:
2+4+2+3
and it will give u the answer : 11, your program would just have to find the operation signs and the different numbers and basically find the answer, this will probably get very complicated when u have to start doin bedmass stuff and use brackets, etc. but it would be real cool :D
nice job btw
P.S> Thnx. Good job on ur games to
ok basically the caclulator would ask you to enter a string of numbers and the calculation to process for each one so instead of asking you to enter 1 number each time you could enter something like this:
1+2*12-16/4
and it would calculate the whole thing, so it would first do the multiplication:
1+24-16/4
then the division
1+24-4
and finally the addition and subtraction
21
and thats it! :D
hope you get well soon ;)
Ok, thnx. That cleared it up. It'll get work on that as soon as I can *which will probably be soon*.Quote:
Originally posted by red_baron
and thats it! :D
hope you get well soon ;)
P.S> thnx, me to :D
P.P.S> Anyone know any FREE host that allows PHP or CGI? I don't want AngelFire, Lycos, or Tripod *already tried to sign up, but never worked* I know it's a bit off topic, but I want a better host then GeoCities.
http://www.tripod.lycos.co.uk
they have a really cool one the best that i know of...
Thnx...I'll try them out.
This is better than the crappy calculator I wrote when I started C++... Good job!
nah, I think Brinkster is better -- NO ADS! WOOHOO!
Thanks. How far did u get on yours? *Trig functions, calc functions, etc...*Quote:
Originally posted by face_master
This is better than the crappy calculator I wrote when I started C++... Good job!
EDIT> I have a Brinkster account also, but I want PHP *I dunno how to use ASP scripts* I might make my brinkster site a mirror though. No Ad's is better, you're right on that part.
mine was basically the same as yours except all it had was the basic * / + - operations (i'm too lazy to write out the words so I use operators ;) )
Kool. I was planning on the basic 4, but decided to make it more.Quote:
Originally posted by face_master
mine was basically the same as yours except all it had was the basic * / + - operations (i'm too lazy to write out the words so I use operators ;) )
that rhymes lol
Hey, you're right! *lol*. Didn't realize that till now...kewl! If anyone knows how to do the operators for the string thing, I'd greatly appreciate any help. I have an idea on it, but I don't think it'll be the right way.
well you can make it a character array, like char input [100];
hmm first check all the values of the array to make sure they are only numbers and operations, then
check the value of array if its a number go to next value if its one of the operators then take the first number call it like num[0] then put the operator as operator[0] then check the next value of array and so on till you finish, then just check for multiply operators first multiply the equivilatn operator value of array from num with the value beside it,,, umm let me give u an example
lets say operator[9] is multiply then you have to multiply num[9] with num[9+1],
then bring all the values of the arrays one down... like:
operatior[9] is now equal to operator[10] and so on gotta do same with the num array. thats a lot of loopin' :p
well thats the best way i know of doin it, it might not be the easiest or best but its somethin.
Ok, thnx. I'll start work on that tomorrow, or maybe tonight, or whatever...heh
lol you reply fast, i post leave for 10 sec come back and you've posted already! well i g2g now, been on the board all day lol :D
I got "E-mail notification" checked, heh. I've been coding practically all day, peace.
Greatest day of all for me! I figured out how to do proportion calculations! It may be a little rusty, but hell, I'm the first!!!!
Here it is, and just for this grand day (well, night where I live), it'll be version 2.0.0!
Fixed a few things, changed a few things. read the "readme.txt" file fore the exact info on what has been modified/deleted. This is version 2.0.1
If you would be willing to do some trig functions in your calculator that would be great. I was going to do it the other day after school for myself, but I thought nah I'm too lazy. The only reason why I was going to do it is because I don't have a graphing calculator. Although, I could download a T189 ROM or something like that. Better yet do it the old fashioned way, which is actually pretty simple.:D
The calculator is fine.. but maybe you should add options in the main menu using up and down keys (like when choosing the OS when you got more than 1 installed on the sys) or at least use getch(); so that the user doesn't have to press enter after his choice (main menu).. The rest is fine :) good job :)
it says in your readme that you really hate Microsoft's calculator. Whats wrong with it??
What you should do for updating your new versions is to put the new version on a new post and then to put the new version on you very first post. For the rest of the versions you should delete them off of your posts to make sure there isn't any confusion.
Btw, there is an error in your latest version. When I enter 10 at the beginning to do a Cube function it closes the program.
make that:Quote:
Originally posted by face_master
Code:while(b = 0)
{
cout << "Please enter a number other than 0 please: ";
cin >> b;
}
while (b==0)
otherwise it has the opposite effect.
I've made a calculator, too. It supports complex numbers, strings, vectors and matrices.
It parses a string like this : "sin (2+4/(4+3i))"
woops, damn i'm retarted ...
I did a selection Demo on this forum.. search for it.. it's pretty easy :p
Sang-drax> It is while(b == 0). I'll take a look and try out your calculator.
Ruski> Ok, thnx. I'll check it out. getch() doesn't work right. Here's the code:
/* ... various code here */
Selection code:
1] Redo
2] return to main menu
3] exit {Quit}
pick.choice = getch();
if(pick.choice == '1')
code();
if(pick.choice == '2')
begin();
if(pick.choice == '3')
quit();
After the math is done, you have to push any of the numbers before the menu shows, then it still doesn't work right.
TechWins> I fixed the press 10 and get quit bug you where having. I forgot to change the command for case 10. I am currently working on sin, but can't get the correct output. The source for it is in the attatchment *along with the other fixes*. I was planning on the trig functions yesterday, but I had to get off the comp. Good idea on the thread/new version thing. I'll start doing that for now on.
NOTE: To get the sin function, you have to enter 13 on the main menu. I haven't added that one in yet becuase it doesn't work.
P.S.: Thanks for all the advice, help, and whatnot so far.
sang-drax> your calc is pretty cool. how did you get the colors to work?? and i found a few bugs. PM me if you want me to let you know what they are.
Ok, i sent you the P.M. Does anyone know of a different way to make a menu? I tried Ruski's way, and it worked if I didn't change anything *including the stuff on the menu*. But if I changed even the slightest thing, it gave me errors. 102 to be exact all saying "cout is an aboligious *or whatever* statement", or something like that. I took out using namespace std; and changed iostream to iostream.h
i think he meant he found bugs in sang-drax's calc, maybe i am mistaken.Code:Ok, i sent you the P.M
He was, but he also found some bugs in my code *well, not bugs, but helped me fix my menu(s)*
I think I know what could be the problem.. If you used gotoxy(); or SetColor(); you couldn't because those functions aren't in the C++ Functions, it's a user-made function so you'll have to include the header file :p ("function.h" or whatever it was..")
Good Luck :)
Good point...heh. But, would you still have to include conio.o *gotoxy is in the conio header(s)*
A header must always be included to use a function that is located inside of it.
Aside from the above mentioned i didn't find much, i would usually be much more helpful but i am ripping out hair with my game haha.
If the program is compiling without any errors then the neccesity for a header is non-existent. Meaning that if you're finding errors with the actual program and not the code it doesn't have to deal with your header files.
RoD> Ok, thnx. That's exactly the same way I feel right now *hehe*.Quote:
Originally posted by TechWins
If the program is compiling without any errors then the neccesity for a header is non-existent. Meaning that if you're finding errors with the actual program and not the code it doesn't have to deal with your header files.
TechWins> I'm getting errors with the cout and cin stuff.
How would I let the user input decimal numbers *like 2.3, and etc...*
Quote:
TechWins> I'm getting errors with the cout and cin stuff.
First one:Quote:
How would I let the user input decimal numbers *like 2.3, and etc...*
Its more then likely a need for <iostream.h> //input output
Second one:
Declare the input variable as a double.
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;
}
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;
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
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.
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.Quote:
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
No idea about that, sorry.Quote:
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.
Nope, gotoxy isnt in conio.h, I did the function gotoxy():Quote:
Originally posted by Quantrizi
Good point...heh. But, would you still have to include conio.o *gotoxy is in the conio header(s)*
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);
}
post the .exe lol not the zip i cant open .zip at school =\
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 :pQuote:
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);
}
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.