If you are suppossed to be writing one, then write one, and if you have a specific problem, check back with us. If you simply want to find one to use, check with Google, there are more than enough out there.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Hi there ,
I need a calculator that is flexible enough to perform
+,-,/,%,^and *.
can you help plz:?:
So basically you want a calculator in java which emulates the one in windows.
There should be lots of examples out there, even some which handles more complex crap like RPN notation. I'm feeling bored (holidays) :sad: I might write a RPN calculator with a nice gui for fun.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
The idea is to help others, not to enlist them to do your homework for you.
You showed no interest at all in doing anything of your own, just sitting back and waiting for a complete solution to be handed to you on a golden platter.
That's not going to fly, especially since you're not paying us consultancy fees (at $150 an hour per person for a minimum of 80 hours per person).
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
and also as to the content of your hard work you have developed a converter(to number from string).That is good but i need inputs to be selected randomly from the file.
The only thing I should ask everybody is how to select interest operands i.e any operands of interest from the text file.
Hullo, can you please explain this in greated detail with an example.
Reading from a file is simple when you know how. But what does the file input look like?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
So you helped the kid by doing his homework for him, now he can claim a decent grade for doing no work at all.
What does that do for the profession, except causing even more unqualified idiots to enter the marketplace?
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Hi Jamttwee
I appreciate your ambition to help me.
What I want is that a calculator that can do calculations based on input from a specific file as well as directly from the numeric button of the interface. The former is more difficult than the latter for me.
So, I would prefer if you do on the former one.
For clarity, the file can be either a text file or a database file. In any case its format looks as below:
"0,2,3,4,5,6,7,8,9,+,-,/,^,%"
Then the system has to store this content into a string array and read from the array for calculation.
Let me knowif any ambiguity
Thanks
Hullo there, I still don't understand the example you have given. Especially since your most recent example contradicts your previous one. That is to say the file will have random real numbers arranged randomly.You have to input thos numbers from the file.
For example if the file has "3,7.9,-9.3,100" then the user has to choose which numbers to take as operands.Its a kind of assigning the text into a string variable, splitting it into parts and manipulating with the elements of the array of the strings.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Hey,
Your replies are annoying me.
Annoying people is much simpler than building them.
This is not expected from a professional.
Plz try to be friendly.
Try to help me rather.
with regards:-|
What's annoying is you can't do a simple calculator program and you want someone else to do it for you.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
It's not annoying if someone has a problem; and the question doesn't seem like a homework request either.
If you're reading exressions from a file, you need a way to parse the contents of the file and recognise operands; java DOES have a simple evaluate function, so you can do Integer.decode(String : s) : int to automatically calculate very simple things (I think, +, - and *). Unfortunately there's no similar Float.decode() or Double.decode() functions.
For more complex things, you'll have to do a String recognitition on every character that COULD be an operand, while buffering values that are numbers; as you reach "lower levels" of the calculation, calculate the results, then keep moving upwards until you get the result of the whole calculation.
Can get very complicated if you want to offer an equivilant inline calculation spec as Java, if you always have 2 operators and an operand it's far easier, if I had the String "5 + 4" I could split it by "+" then add the contents of split[0] and split[2], if it didn't split, I could then try splitting by "*" and so on.
I don't know if Java supports regular expressions in the String.split() function, that would be much helpful; although I suppose you'd never know where your operators were before the split.
Java is quite different from VB; there are methodical similarilities but the structure is far from. How would you do it in VB? the same method will probably apply to Java, if missing functions are a problem, think about what the VB functions actually do, and all of them (except Windows API depents/calls) will translate easily into Java.
Matt
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
you can bring the numbers from the text file easily enough, do you know how to do java file access?
getting operators from text in actual methods is more difficult, you'll either have to pre-write possible methods in your java app and chose one based on comparison, or make your app extensible/updatable and allow your user to write classes to handle their custom operations.
Matt
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
In that link I gave you open up the CalcGUI class.
In there find the line:-
String buttonOrder = "789456123 0 ";
E.g eth.txt="0,2,4,1,7,8,9,6,+,-,/"
Change the line to this:-
String buttonOrder = "02417896";
You'll notice the interface has changed. So effectively all you should be doing is reading your stuff from the text file and assigning that line to the variable buttonOrder ?
With the exception of the operators it should be as simple as that?
Yes? No?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439