Jack Higgs

Greenhorn
+ Follow
since Jan 02, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jack Higgs

I can see what it's doing (sort of!), I just don't know how to express it mathematically or as an algorithm.
17 years ago
Ok, it's a reverse polish calculator I'm analysing.

When I input:

1234
2345
3456
d
+
d
+
d
=

I get an output:

1234
2345
3456
d
1234
2345
3456
+
d
1234
5801
+
d
7035
=
7035

I'm unsure as to what the behaviour of d is. I need to be able to program what d does to do this question on a past exam paper (I'm revising). Any ideas how to represent what d does?

Cheers
17 years ago
Cheers, the exists method has cleared that one up for me! Sometimes when you're relatively new to Java you don't know these methods exist, and you make the problem appear much harder than it is!
17 years ago
Ok. I have a connect 4 program working fine, the game plays and all is good. What I want to do is allow a player to save the game in its current state, and load it back up again. The best way of doing this in the context of my program is to create a new text file containing all relevent variables for each saved game so as to make parsing relatively simple.

Obviously this will mean that a user can't make two text files with the same name otherwise problems will occur! Therefore I need a method to look at the current directory (ie the one the java file is in) for text files with the same name as the one the user specified. If there is one with the same name then the method should return an error and the user should be forced to type in a new name etc etc. My UI is entirely text-based by the way!

Anyone got any ideas, algorithms, links as to how I could go about this?

Cheers bluds.
17 years ago
Write a program in Java that takes as input a mathematical expression consisting of decimal numbers and the four basic mathematical operators (addition, subtraction, multiplication and division) and nested mathematical expressions, and evaluates this expression.

Some examples:
� 5 + 6 * 2
� (5 + 4) * (4 - 2)
� (4 + (2 * (2 - 1))) * 1.2

Any ideas as to how I could go about this? Any general algorithms would be good (I'm certainly not asking any of you to supply detailed code, as that would defeat the object). I think you have to use a composite design pattern?

Cheers
__________________
17 years ago