image provider

hex calculator


Disclaimer

This essay does not describe an existing computer program, just one that should exist. This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have prepared to help you is right here.

This project outline is not like the artificial, tidy little problems you are spoon-fed in school, when all the facts you need are included, nothing extraneous is mentioned, the answer is fully specified, along with hints to nudge you toward a single expected canonical solution. This project is much more like the real world of messy problems where it is up to you to fully the define the end point, or a series of ever more difficult versions of this project and research the information yourself to solve them.

Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; or give you any additional materials. I have too many other projects of my own.

Though I am a programmer by profession, I don’t do people’s homework for them. That just robs them of an education.

You have my full permission to implement this project in any way you please and to keep all the profits from your endeavour.

Please do not email me about this project without reading the disclaimer above.

My two hand-held hex calculators vanished. You can’t buy hand held calculators anymore that do hexadecimal and octal. Your task is to create a Java programmer’s calculator that functions as an Applet, application or Java Web Start weblet.

If all you want is a hex calculator, you don’t have to implement this project. You can use the one that comes with Windows in the accessories folder. In scientific mode, it can do hex, decimal, octal and binary. This project is about creating a hex calculator especially useful to Java programmers.

It has simulated buttons you click with the mouse.

It is aimed at Java programmers. It calculates in long, int, double or float. It lets you enter or view the display in 16-bit chars, 8-bit chars, hex, decimal, octal or binary.

An RPN (Reverse Polish Notation) (Reverse Polish Notation) calculator would be easiest to implement. Operands work on the top two elements of the stack and replace them with the answer. You need Forth-like operands DUP DROP SWAP OVER ROT -ROT as well as all the java operators. Since it is written in Java, it naturally produces the exact same results Java does.

You might create buttons for much of the Math library too.

You could have several named stores (variables) and allow the user to make up new varible names to store results under on the fly.

Your buttons could relabel themselves in the different modes. You can have almost all the buttons you want. You don’t have to make buttons do quadruple duty the way they do in a hand-held.

Now comes the interesting part. The calculator is user-extensible. The end user can write his own functions in Java and create new buttons for them. All he has to do is write a class that implements your interface and register it.

It could have an eval function that can evaluate any Java expression. You handle it by embedding it in some java source code and invoking the Jikes or Javac compiler dynamically.

If you want to do an infix calculator that understands (), you will need a parser to analyse the syntax.

One way to design the calculator is an interface that collects keystrokes and as finite state automaton that changes state with each keystrokes and emits the contents of several displays.

Most onscreen calculators fail because they keep getting buried, or won’t get out the way. You want to create ways to make your calculator change size, move out the way and restore conveniently.

An undo/redo button would save a lot of rekeying.

Check out Google for programmer calculator to look at other on-screen calculators.

Class.forName
finite state automaton
parser
programmer’s calculator

This page is posted
on the web at:

http://mindprod.com/project/hexcalc.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\project\hexcalc.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.81.221.121]
You are visitor number