hex calculator hex calculator
home Student Projects no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. It does not describe an actual complete program. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; I have too many other projects of my own.

I do contract work for a living, which could include writing a program such as this. However, 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 any way you please.

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) 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 an interface that collects keystrokes, and as finite state automaton that changes state with each keystrokes, and emits the contents of several displays.

Class.forName
finite state automaton
parser

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] Spread the Net
You are visitor number 15,059.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/project/hexcalc.html J:\mindprod\project\hexcalc.html